use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class RegLoadConvertorTest method setUp.
@Before
public void setUp() throws Exception {
final NxRegLoad nxRegLoad = Mockito.mock(NxRegLoad.class);
final Dst dst = Mockito.mock(Dst.class);
when(dst.getStart()).thenReturn(1);
when(dst.getEnd()).thenReturn(2);
when(nxRegLoad.getDst()).thenReturn(dst);
when(nxRegLoad.getValue()).thenReturn(BigInteger.valueOf(3L));
when(nxRegLoad.getDst().getDstChoice()).thenReturn(Mockito.mock(DstNxTunIdCase.class));
when(actionsCase.getNxRegLoad()).thenReturn(nxRegLoad);
final ActionRegLoad actionRegLoad = Mockito.mock(ActionRegLoad.class);
final NxActionRegLoad nxActionRegLoad = Mockito.mock(NxActionRegLoad.class);
when(nxActionRegLoad.getDst()).thenReturn(NiciraMatchCodecs.ICMP_TYPE_CODEC.getHeaderWithoutHasMask().toLong());
when(nxActionRegLoad.getOfsNbits()).thenReturn(4);
when(nxActionRegLoad.getValue()).thenReturn(BigInteger.ONE);
when(actionRegLoad.getNxActionRegLoad()).thenReturn(nxActionRegLoad);
when(action.getActionChoice()).thenReturn(actionRegLoad);
regLoadConvertor = new RegLoadConvertor();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class MultipathConvertor method convert.
@Override
public Action convert(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
Preconditions.checkArgument(nxActionArg instanceof NxActionMultipathGrouping);
NxActionMultipathGrouping nxAction = (NxActionMultipathGrouping) nxActionArg;
NxActionMultipathBuilder nxActionMultipathBuilder = new NxActionMultipathBuilder();
nxActionMultipathBuilder.setFields(nxAction.getNxMultipath().getFields());
nxActionMultipathBuilder.setBasis(nxAction.getNxMultipath().getBasis());
nxActionMultipathBuilder.setAlgorithm(nxAction.getNxMultipath().getAlgorithm());
nxActionMultipathBuilder.setMaxLink(nxAction.getNxMultipath().getMaxLink());
nxActionMultipathBuilder.setArg(nxAction.getNxMultipath().getArg());
Dst dst = nxAction.getNxMultipath().getDst();
nxActionMultipathBuilder.setOfsNbits(dst.getStart() << 6 | dst.getEnd() - dst.getStart());
nxActionMultipathBuilder.setDst(RegMoveConvertor.resolveDst(dst.getDstChoice()));
ActionMultipathBuilder actionMultipathBuilder = new ActionMultipathBuilder();
actionMultipathBuilder.setNxActionMultipath(nxActionMultipathBuilder.build());
return ActionUtil.createAction(actionMultipathBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class RegLoadConvertor method convert.
@Override
public Action convert(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxActionArg) {
Preconditions.checkArgument(nxActionArg instanceof NxActionRegLoadGrouping);
NxActionRegLoadGrouping nxAction = (NxActionRegLoadGrouping) nxActionArg;
Dst dst = nxAction.getNxRegLoad().getDst();
final ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder();
NxActionRegLoadBuilder nxActionRegLoadBuilder = new NxActionRegLoadBuilder();
nxActionRegLoadBuilder.setDst(RegMoveConvertor.resolveDst(dst.getDstChoice()));
nxActionRegLoadBuilder.setOfsNbits(dst.getStart() << 6 | dst.getEnd() - dst.getStart());
nxActionRegLoadBuilder.setValue(nxAction.getNxRegLoad().getValue());
actionRegLoadBuilder.setNxActionRegLoad(nxActionRegLoadBuilder.build());
return ActionUtil.createAction(actionRegLoadBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithIpv6ArbitraryMasks.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithIpv6ArbitraryMasks() {
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(Ipv6Src.class);
entriesBuilder.setHasMask(true);
final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
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());
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("2002:2002:2002:2002:2002:2002:2002:2002"));
ipv6AddressBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255 });
ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.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", "1001:1001:1001:1001:1001:1001:1001:1001", ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002", ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.multipath.grouping.nx.multipath.Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask() {
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(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());
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());
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());
}
Aggregations