use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata in project openflowplugin by opendaylight.
the class WriteMetadataInstructionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final long metadata = 10L;
final long metadataMask = 10L;
final Instruction instruction = new WriteMetadataCaseBuilder().setWriteMetadata(new WriteMetadataBuilder().setMetadata(BigInteger.valueOf(metadata)).setMetadataMask(BigInteger.valueOf(metadataMask)).build()).build();
assertInstruction(instruction, out -> {
out.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
assertEquals(out.readLong(), metadata);
assertEquals(out.readLong(), metadataMask);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata in project openflowplugin by opendaylight.
the class MetadataEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final BigInteger metadata = BigInteger.valueOf(20);
final BigInteger metadataMask = BigInteger.valueOf(30);
writeHeader(in, false);
in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength()));
assertEquals(metadata, deserialize(in).getMetadata().getMetadata());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, getValueLength()));
in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadataMask, getValueLength()));
final Metadata desMetadata = deserialize(in).getMetadata();
assertEquals(metadata, desMetadata.getMetadata());
assertEquals(metadataMask, desMetadata.getMetadataMask());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata in project openflowplugin by opendaylight.
the class WriteMetadataInstructionDeserializerTest method testDeserialize.
@Test
public void testDeserialize() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final BigInteger metadata = BigInteger.valueOf(1234L);
final BigInteger metadataMask = BigInteger.valueOf(9876L);
writeHeader(in);
in.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadataMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
final Instruction instruction = deserializeInstruction(in);
assertEquals(WriteMetadataCase.class, instruction.getImplementedInterface());
assertArrayEquals(ByteUtil.convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES), ByteUtil.convertBigIntegerToNBytes(WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
assertArrayEquals(ByteUtil.convertBigIntegerToNBytes(metadataMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES), ByteUtil.convertBigIntegerToNBytes(WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method createInstructions.
private List<Instruction> createInstructions() {
final List<Instruction> instructions = new ArrayList<>();
InstructionBuilder insBuilder = new InstructionBuilder();
GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder instructionBuilder = new GotoTableBuilder();
instructionBuilder.setTableId((short) 43);
goToCaseBuilder.setGotoTable(instructionBuilder.build());
insBuilder.setInstructionChoice(goToCaseBuilder.build());
instructions.add(insBuilder.build());
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
byte[] metadata = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
metadataBuilder.setMetadata(metadata);
byte[] metadataMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
metadataBuilder.setMetadataMask(metadataMask);
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
insBuilder.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(insBuilder.build());
insBuilder = new InstructionBuilder();
final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
final ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
final List<Action> actions = new ArrayList<>();
final ActionBuilder actionBuilder = new ActionBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
actionsBuilder.setAction(actions);
applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(insBuilder.build());
return instructions;
}
Aggregations