use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginGroupTestCommandProvider method createInportOutputAction.
private List<Action> createInportOutputAction() {
ActionBuilder ab = new ActionBuilder();
OutputActionBuilder output = new OutputActionBuilder();
output.setMaxLength(30);
Uri value = new Uri(OutputPortValues.INPORT.toString());
output.setOutputNodeConnector(value);
ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
ab.setKey(new ActionKey(0));
List<Action> actions = new ArrayList<>();
actions.add(ab.build());
return actions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder in project openflowplugin by opendaylight.
the class OF13InstructionsSerializerTest method test.
/**
* Testing instructions translation.
*/
@Test
public void test() {
final List<Instruction> instructions = new ArrayList<>();
// Goto_table instruction
InstructionBuilder builder = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder instructionBuilder = new GotoTableBuilder();
instructionBuilder.setTableId((short) 5);
gotoCaseBuilder.setGotoTable(instructionBuilder.build());
builder.setInstructionChoice(gotoCaseBuilder.build());
instructions.add(builder.build());
// Write_metadata instruction
builder = new InstructionBuilder();
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
builder.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(builder.build());
// Clear_actions instruction
builder = new InstructionBuilder();
builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
instructions.add(builder.build());
// Meter instruction
builder = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(42L);
meterCaseBuilder.setMeter(meterBuilder.build());
builder.setInstructionChoice(meterCaseBuilder.build());
instructions.add(builder.build());
// Write_actions instruction
builder = new InstructionBuilder();
final WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
final WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(45L));
outputBuilder.setMaxLength(55);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
ttlActionBuilder.setNwTtl((short) 64);
ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
actionBuilder.setActionChoice(ttlCaseBuilder.build());
actions.add(actionBuilder.build());
writeActionsBuilder.setAction(actions);
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
builder.setInstructionChoice(writeActionsCaseBuilder.build());
instructions.add(builder.build());
// Apply_actions instruction
builder = new InstructionBuilder();
final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
final ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
vlanBuilder.setEthertype(new EtherType(new EtherType(14)));
vlanCaseBuilder.setPushVlanAction(vlanBuilder.build());
actionBuilder.setActionChoice(vlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
applyActionsBuilder.setAction(actions);
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
builder.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(builder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(instructions, TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);
Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
out.skipBytes(4);
byte[] actual = new byte[8];
out.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual));
actual = new byte[8];
out.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual));
Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt());
Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertTrue("Not all data were read", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder in project openflowplugin by opendaylight.
the class FlowUtils method createDirectMacToMacFlow.
/**
* Returns a {@link FlowBuilder} forwarding all packets to controller port.
*/
public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac, final MacAddress dstMac, final NodeConnectorRef dstPort) {
FlowBuilder macToMacFlow = new FlowBuilder().setTableId(tableId).setFlowName("mac2mac");
macToMacFlow.setId(new FlowId(Long.toString(macToMacFlow.hashCode())));
EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build()).setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build()).build();
MatchBuilder match = new MatchBuilder();
match.setEthernetMatch(ethernetMatch);
Uri outputPort = dstPort.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId();
Action outputToControllerAction = new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().setMaxLength(Integer.valueOf(0xffff)).setOutputNodeConnector(outputPort).build()).build()).build();
// Create an Apply Action
ApplyActions applyActions = new ApplyActionsBuilder().setAction(ImmutableList.of(outputToControllerAction)).build();
// Wrap our Apply Action in an Instruction
Instruction applyActionsInstruction = new InstructionBuilder().setOrder(0).setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActions).build()).build();
// Put our Instruction in a list of Instructions
macToMacFlow.setMatch(new MatchBuilder().setEthernetMatch(ethernetMatch).build()).setInstructions(new InstructionsBuilder().setInstruction(ImmutableList.of(applyActionsInstruction)).build()).setPriority(priority).setBufferId(OFConstants.OFP_NO_BUFFER).setHardTimeout(0).setIdleTimeout(0).setFlags(new FlowModFlags(false, false, false, false, false));
return macToMacFlow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder in project openflowplugin by opendaylight.
the class FlowModInputMessageFactoryTest method testFlowModInputMessageFactory.
/**
* Testing of {@link FlowModInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testFlowModInputMessageFactory() throws Exception {
FlowModInputBuilder builder = new FlowModInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
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);
builder.setHardTimeout(0);
builder.setPriority(126);
builder.setBufferId(2L);
builder.setOutPort(new PortNumber(4422L));
builder.setOutGroup(98L);
builder.setFlags(new FlowModFlags(true, false, true, false, true));
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(42L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 4);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
matchBuilder.setMatchEntry(entries);
builder.setMatch(matchBuilder.build());
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();
metadataBuilder.setMetadata(cookie);
metadataBuilder.setMetadataMask(cookieMask);
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());
builder.setInstruction(instructions);
final FlowModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
// simulate parent message
out.writeInt(1);
out.writeZero(2);
out.writeShort(3);
flowModFactory.serialize(message, out);
// read parent message
out.readInt();
out.skipBytes(2);
out.readShort();
BufferHelper.checkHeaderV13(out, (byte) 14, 128);
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());
Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort());
Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt());
Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt());
Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt());
Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort()));
out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE);
Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());
short fieldAndMask = out.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());
fieldAndMask = out.readUnsignedByte();
Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte());
out.skipBytes(7);
Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
byte[] cookieRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
out.readBytes(cookieRead);
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.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong max-length", 52, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder in project openflowplugin by opendaylight.
the class OF13ActionsSerializerTest method test.
/**
* Testing correct serialization of actions.
*/
@Test
public void test() {
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
setMplsTtlBuilder.setMplsTtl((short) 4);
setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
pushVlanBuilder.setEthertype(new EtherType(new EtherType(16)));
pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
pushMplsBuilder.setEthertype(new EtherType(new EtherType(17)));
pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
popMplsBuilder.setEthertype(new EtherType(new EtherType(18)));
popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
actionBuilder.setActionChoice(popMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
setQueueBuilder.setQueueId(1234L);
setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
actionBuilder.setActionChoice(setQueueCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroupId(555L);
groupCaseBuilder.setGroupAction(groupActionBuilder.build());
actionBuilder.setActionChoice(groupCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
nwTtlBuilder.setNwTtl((short) 8);
nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(InPort.class);
matchBuilder.setHasMask(false);
InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
InPortBuilder inPortBuilder = new InPortBuilder();
inPortBuilder.setPortNumber(new PortNumber(1L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
matchBuilder.setMatchEntryValue(inPortCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
pushPbbBuilder.setEthertype(new EtherType(new EtherType(19)));
pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt());
Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt());
Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort());
Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte());
Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Aggregations