use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project openflowplugin by opendaylight.
the class OF10ActionsDeserializerTest method test.
/**
* Testing correct deserialization of actions (OF v1.0).
*/
@Test
public void test() {
ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " + "00 01 00 08 10 10 00 00 " + "00 02 00 08 25 00 00 00 " + "00 03 00 08 00 00 00 00 " + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " + "00 06 00 08 0A 00 00 01 " + "00 07 00 08 0B 00 00 02 " + "00 08 00 08 01 00 00 00 " + "00 09 00 08 00 02 00 00 " + "00 0A 00 08 00 03 00 00 " + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30");
// skip XID
message.skipBytes(4);
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, message.readableBytes(), message, keyMaker, registry);
Assert.assertEquals("Wrong number of actions", 12, actions.size());
Action action1 = actions.get(0);
Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong port", 16, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong max-length", 8192, ((OutputActionCase) action1.getActionChoice()).getOutputAction().getMaxLength().intValue());
Action action2 = actions.get(1);
Assert.assertTrue("Wrong action type", action2.getActionChoice() instanceof SetVlanVidCase);
Assert.assertEquals("Wrong vlan-vid", 4112, ((SetVlanVidCase) action2.getActionChoice()).getSetVlanVidAction().getVlanVid().intValue());
Action action3 = actions.get(2);
Assert.assertTrue("Wrong action type", action3.getActionChoice() instanceof SetVlanPcpCase);
Assert.assertEquals("Wrong vlan-pcp", 37, ((SetVlanPcpCase) action3.getActionChoice()).getSetVlanPcpAction().getVlanPcp().intValue());
Action action4 = actions.get(3);
Assert.assertTrue("Wrong action type", action4.getActionChoice() instanceof StripVlanCase);
Action action5 = actions.get(4);
Assert.assertTrue("Wrong action type", action5.getActionChoice() instanceof SetDlSrcCase);
Assert.assertEquals("Wrong dl-src", "01:02:03:04:05:06", ((SetDlSrcCase) action5.getActionChoice()).getSetDlSrcAction().getDlSrcAddress().getValue());
Action action6 = actions.get(5);
Assert.assertTrue("Wrong action type", action6.getActionChoice() instanceof SetDlDstCase);
Assert.assertEquals("Wrong dl-dst", "02:03:04:05:06:07", ((SetDlDstCase) action6.getActionChoice()).getSetDlDstAction().getDlDstAddress().getValue());
Action action7 = actions.get(6);
Assert.assertTrue("Wrong action type", action7.getActionChoice() instanceof SetNwSrcCase);
Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), ((SetNwSrcCase) action7.getActionChoice()).getSetNwSrcAction().getIpAddress());
Action action8 = actions.get(7);
Assert.assertTrue("Wrong action type", action8.getActionChoice() instanceof SetNwDstCase);
Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), ((SetNwDstCase) action8.getActionChoice()).getSetNwDstAction().getIpAddress());
Action action9 = actions.get(8);
Assert.assertTrue("Wrong action type", action9.getActionChoice() instanceof SetNwTosCase);
Assert.assertEquals("Wrong nw-tos", 1, ((SetNwTosCase) action9.getActionChoice()).getSetNwTosAction().getNwTos().intValue());
Action action10 = actions.get(9);
Assert.assertTrue("Wrong action type", action10.getActionChoice() instanceof SetTpSrcCase);
Assert.assertEquals("Wrong port", 2, ((SetTpSrcCase) action10.getActionChoice()).getSetTpSrcAction().getPort().getValue().intValue());
Action action11 = actions.get(10);
Assert.assertTrue("Wrong action type", action11.getActionChoice() instanceof SetTpDstCase);
Assert.assertEquals("Wrong port", 3, ((SetTpDstCase) action11.getActionChoice()).getSetTpDstAction().getPort().getValue().intValue());
Action action12 = actions.get(11);
Assert.assertTrue("Wrong action type", action12.getActionChoice() instanceof EnqueueCase);
Assert.assertEquals("Wrong port", 4, ((EnqueueCase) action12.getActionChoice()).getEnqueueAction().getPort().getValue().intValue());
Assert.assertEquals("Wrong queue-id", 48, ((EnqueueCase) action12.getActionChoice()).getEnqueueAction().getQueueId().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project openflowplugin by opendaylight.
the class ActionConvertorV10Test method testGetActions.
/**
* Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
@Test
public void testGetActions() {
ActionBuilder actionBuilder = new ActionBuilder();
SetVlanPcpActionCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpActionCaseBuilder();
SetVlanPcpActionBuilder pcpBuilder = new SetVlanPcpActionBuilder();
pcpBuilder.setVlanPcp(new VlanPcp((short) 7));
vlanPcpCaseBuilder.setSetVlanPcpAction(pcpBuilder.build());
actionBuilder.setAction(vlanPcpCaseBuilder.build());
actionBuilder.setOrder(0);
List<Action> salActions = new ArrayList<>();
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
StripVlanActionCaseBuilder stripCaseBuilder = new StripVlanActionCaseBuilder();
StripVlanActionBuilder stripBuilder = new StripVlanActionBuilder();
stripCaseBuilder.setStripVlanAction(stripBuilder.build());
actionBuilder.setAction(stripCaseBuilder.build());
actionBuilder.setOrder(1);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlDstActionCaseBuilder dlDstCaseBuilder = new SetDlDstActionCaseBuilder();
SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
dlDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
actionBuilder.setAction(dlDstCaseBuilder.build());
actionBuilder.setOrder(2);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlSrcActionCaseBuilder dlSrcCaseBuilder = new SetDlSrcActionCaseBuilder();
SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
dlSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
actionBuilder.setAction(dlSrcCaseBuilder.build());
actionBuilder.setOrder(3);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
Ipv4Builder ipv4Builder = new Ipv4Builder();
/* Use prefix which is correct in canonical representation in test */
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));
nwSrcBuilder.setAddress(ipv4Builder.build());
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
actionBuilder.setAction(nwSrcCaseBuilder.build());
actionBuilder.setOrder(4);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
ipv4Builder = new Ipv4Builder();
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.2/32"));
nwDstBuilder.setAddress(ipv4Builder.build());
SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setAction(nwDstCaseBuilder.build());
actionBuilder.setOrder(5);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpSrcActionCaseBuilder tpSrcCaseBuilder = new SetTpSrcActionCaseBuilder();
SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
tpSrcBuilder.setPort(new PortNumber(54));
tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
actionBuilder.setAction(tpSrcCaseBuilder.build());
actionBuilder.setOrder(6);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpDstActionCaseBuilder tpDstCaseBuilder = new SetTpDstActionCaseBuilder();
SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
tpDstBuilder.setPort(new PortNumber(45));
tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
actionBuilder.setAction(tpDstCaseBuilder.build());
actionBuilder.setOrder(7);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTosActionCaseBuilder tosCaseBuilder = new SetNwTosActionCaseBuilder();
SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
tosBuilder.setTos(18);
tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
actionBuilder.setAction(tosCaseBuilder.build());
actionBuilder.setOrder(8);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetVlanIdActionCaseBuilder vlanIdCaseBuilder = new SetVlanIdActionCaseBuilder();
SetVlanIdActionBuilder vlanIdBuilder = new SetVlanIdActionBuilder();
vlanIdBuilder.setVlanId(new VlanId(22));
vlanIdCaseBuilder.setSetVlanIdAction(vlanIdBuilder.build());
actionBuilder.setAction(vlanIdCaseBuilder.build());
actionBuilder.setOrder(9);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder();
actionBuilder.setAction(popVlanActionCaseBuilder.build());
actionBuilder.setOrder(10);
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
vlanMatchBuilder.setVlanId(new VlanIdBuilder().setVlanId(new VlanId(22)).build());
setFieldBuilder.setVlanMatch(vlanMatchBuilder.build());
setFieldCaseBuilder.setSetField(setFieldBuilder.build());
actionBuilder.setAction(setFieldCaseBuilder.build());
actionBuilder.setOrder(11);
salActions.add(actionBuilder.build());
IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProto(IpVersion.Ipv4);
MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());
FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());
Flow flow = flowBld.build();
ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(new BigInteger("42"));
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> actionsOptional = convertorManager.convert(salActions, data);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = actionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of actions", 12, actions.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetVlanPcpCase", action.getActionChoice().getImplementedInterface().getName());
SetVlanPcpCase setVlanPcpCase = (SetVlanPcpCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan pcp", 7, setVlanPcpCase.getSetVlanPcpAction().getVlanPcp().intValue());
action = actions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());
action = actions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetDlDstCase", action.getActionChoice().getImplementedInterface().getName());
SetDlDstCase setDlDstCase = (SetDlDstCase) action.getActionChoice();
Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06", setDlDstCase.getSetDlDstAction().getDlDstAddress().getValue());
action = actions.get(3);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetDlSrcCase", action.getActionChoice().getImplementedInterface().getName());
SetDlSrcCase setDlSrcCase = (SetDlSrcCase) action.getActionChoice();
Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05", setDlSrcCase.getSetDlSrcAction().getDlSrcAddress().getValue());
action = actions.get(4);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetNwSrcCase", action.getActionChoice().getImplementedInterface().getName());
SetNwSrcCase setNwSrcCase = (SetNwSrcCase) action.getActionChoice();
Assert.assertEquals("Wrong nw src", "10.0.0.0", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());
action = actions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetNwDstCase", action.getActionChoice().getImplementedInterface().getName());
SetNwDstCase setNwDstCase = (SetNwDstCase) action.getActionChoice();
Assert.assertEquals("Wrong nw dst", "10.0.0.2", setNwDstCase.getSetNwDstAction().getIpAddress().getValue());
action = actions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetTpSrcCase", action.getActionChoice().getImplementedInterface().getName());
SetTpSrcCase setTpSrcCase = (SetTpSrcCase) action.getActionChoice();
Assert.assertEquals("Wrong tp src", 54, setTpSrcCase.getSetTpSrcAction().getPort().getValue().intValue());
action = actions.get(7);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetTpDstCase", action.getActionChoice().getImplementedInterface().getName());
SetTpDstCase setTpDstCase = (SetTpDstCase) action.getActionChoice();
Assert.assertEquals("Wrong tp dst", 45, setTpDstCase.getSetTpDstAction().getPort().getValue().intValue());
action = actions.get(8);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetNwTosCase", action.getActionChoice().getImplementedInterface().getName());
SetNwTosCase setNwTosCase = (SetNwTosCase) action.getActionChoice();
Assert.assertEquals("Wrong nw tos", 18, setNwTosCase.getSetNwTosAction().getNwTos().intValue());
action = actions.get(9);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());
SetVlanVidCase setVlanVidCase = (SetVlanVidCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());
action = actions.get(10);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());
action = actions.get(11);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());
setVlanVidCase = (SetVlanVidCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(true);
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Dst.class);
entriesBuilder.setHasMask(true);
final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
ipv6AddressBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Src.class);
entriesBuilder.setHasMask(true);
final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
ipv6SrcBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255 });
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002", ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001", ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithDstArbitraryBitMaskAndSrcCidrMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithDstArbitraryBitMaskAndSrcCidrMask() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(true);
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(true);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
ipv4AddressBuilder.setMask(new byte[] { (byte) 255, 0, (byte) 240, 0 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(true);
final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
ipv4SrcBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();
final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1", ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1", ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithMasks.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithMasks() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(true);
final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();
metadataBuilder.setMetadata(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });
metadataBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 });
metadataCaseBuilder.setMetadata(metadataBuilder.build());
entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthDst.class);
entriesBuilder.setHasMask(true);
final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
final EthDstBuilder ethDstBuilder = new EthDstBuilder();
ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));
ethDstBuilder.setMask(new byte[] { 0, 0, 0, 0, 1, 1 });
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthSrc.class);
entriesBuilder.setHasMask(true);
final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));
ethSrcBuilder.setMask(new byte[] { 0, 0, 0, 0, 2, 2 });
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanVid.class);
entriesBuilder.setHasMask(true);
final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setVlanVid(4);
vlanVidBuilder.setCfiBit(true);
vlanVidBuilder.setMask(new byte[] { 0, 4 });
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Src.class);
entriesBuilder.setHasMask(true);
final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
ipv4SrcBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(true);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
ipv4AddressBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 240, 0 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(PbbIsid.class);
entriesBuilder.setHasMask(true);
final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
pbbIsidBuilder.setIsid(23L);
pbbIsidBuilder.setMask(new byte[] { 0, 0, 7 });
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TunnelId.class);
entriesBuilder.setHasMask(true);
final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
tunnelIdBuilder.setTunnelId(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 });
tunnelIdBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 8 });
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();
Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }), builtMatch.getMetadata().getMetadata());
Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }), builtMatch.getMetadata().getMetadataMask());
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());
Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());
Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());
Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());
final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue());
Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());
Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }), builtMatch.getTunnel().getTunnelId());
}
Aggregations