Search in sources :

Example 1 with WriteMetadata

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());
}
Also used : WriteMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder)

Example 2 with WriteMetadata

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 };
}
Also used : WriteMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) BigInteger(java.math.BigInteger) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 3 with WriteMetadata

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());
}
Also used : WriteMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 4 with WriteMetadata

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));
}
Also used : WriteMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata)

Example 5 with WriteMetadata

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());
}
Also used : WriteMetadata(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase)

Aggregations

WriteMetadata (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadata)4 WriteMetadataCase (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase)2 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)2 BigInteger (java.math.BigInteger)1 WriteMetadataCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase)1 WriteMetadataCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder)1 WriteMetadata (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata)1 WriteMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder)1 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder)1