import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntriesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
/**
* @author timotej.kubas
public void testFlowModInputMessageFactory() throws Exception {
FlowModInputBuilder builder = new FlowModInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
- byte[] cookie = new byte[]{0x00, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};
- builder.setCookie(new BigInteger(cookie));
- byte[] cookieMask = new byte[]{0x01, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};
- builder.setCookieMask(new BigInteger(cookieMask));
+ byte[] cookie = new byte[]{(byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01};
+ builder.setCookie(new BigInteger(1, cookie));
+ byte[] cookieMask = new byte[]{(byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30};
+ builder.setCookieMask(new BigInteger(1, cookieMask));
builder.setTableId(new TableId(65L));
builder.setCommand(FlowModCommand.forValue(2));
builder.setIdleTimeout(12);
entries.add(entriesBuilder.build());
matchBuilder.setMatchEntries(entries);
builder.setMatch(matchBuilder.build());
- List<Instructions> instructions = new ArrayList<>();
- InstructionsBuilder insBuilder = new InstructionsBuilder();
+ List<Instruction> instructions = new ArrayList<>();
+ InstructionBuilder insBuilder = new InstructionBuilder();
insBuilder.setType(GotoTable.class);
TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();
idBuilder.setTableId((short) 43);
metaBuilder.setMetadataMask(cookieMask);
insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
instructions.add(insBuilder.build());
- builder.setInstructions(instructions);
+ insBuilder = new InstructionBuilder();
+ insBuilder.setType(ApplyActions.class);
+ insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
+ instructions.add(insBuilder.build());
+ builder.setInstruction(instructions);
FlowModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);
BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message));
- Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), out.readLong());
- Assert.assertEquals("Wrong cookieMask", message.getCookieMask().longValue(), out.readLong());
+ cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+ out.readBytes(cookie);
+ Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie));
+ cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+ out.readBytes(cookieMask);
+ Assert.assertEquals("Wrong cookieMask", message.getCookieMask(), new BigInteger(1, cookieMask));
Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte());
Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte());
Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort());
byte[] cookieMaskRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(cookieMaskRead);
Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead);
- Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead);
+ Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead);
+ Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
+ Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
+ out.skipBytes(4);
+ Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
private static FlowModFlags createFlowModFlagsFromBitmap(int input){