use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeArpMatch.
@Test
public void normalizeArpMatch() {
final int arpOp = 10;
final String source = "192.168.1.2/24";
final String destination = "192.168.2.2/24";
final MacAddress sourceHw = new MacAddress("01:23:45:AB:CD:EF");
final MacAddress dstHw = new MacAddress("01:23:45:AB:C0:EF");
final MacAddress mask = new MacAddress("FF:FF:FF:FF:FF:FF");
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeArpMatch(new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpOp(10).setArpSourceTransportAddress(new Ipv4Prefix(source)).setArpTargetTransportAddress(new Ipv4Prefix(destination)).setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(dstHw).setMask(mask).build()).setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(sourceHw).setMask(mask).build()).build()));
assertEquals(arpOp, ArpMatch.class.cast(matchBuilder.getLayer3Match()).getArpOp().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeEthernetMatch.
@Test
public void normalizeEthernetMatch() {
final MacAddress left = new MacAddress("01:23:45:AB:CD:EF");
final MacAddress leftMask = new MacAddress("FF:FF:FF:FF:FF:FF");
final MacAddress right = new MacAddress("01:23:45:ab:cd:ef");
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeEthernetMatch(new MatchBuilder().setEthernetMatch(new EthernetMatchBuilder().setEthernetSource(new EthernetSourceBuilder().setAddress(left).setMask(leftMask).build()).setEthernetDestination(new EthernetDestinationBuilder().setAddress(left).setMask(leftMask).build()).build()));
assertEquals(right, matchBuilder.getEthernetMatch().getEthernetSource().getAddress());
assertEquals(right, matchBuilder.getEthernetMatch().getEthernetDestination().getAddress());
assertNull(matchBuilder.getEthernetMatch().getEthernetSource().getMask());
assertNull(matchBuilder.getEthernetMatch().getEthernetDestination().getMask());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeTunnelIpv4Match.
@Test
public void normalizeTunnelIpv4Match() {
final String source = "192.168.1.2/24";
final String destination = "192.168.2.2/24";
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeTunnelIpv4Match(new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix(source)).setTunnelIpv4Destination(new Ipv4Prefix(destination)).build()));
assertEquals("192.168.1.0/24", TunnelIpv4Match.class.cast(matchBuilder.getLayer3Match()).getTunnelIpv4Source().getValue());
assertEquals("192.168.2.0/24", TunnelIpv4Match.class.cast(matchBuilder.getLayer3Match()).getTunnelIpv4Destination().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder in project openflowplugin by opendaylight.
the class GroupingLooseResolverTest method testGetExtension.
@Test
public void testGetExtension() {
GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup = new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
eqGroup.add(GeneralAugMatchNodesNodeTableFlow.class);
eqGroup.add(GeneralAugMatchNotifPacketIn.class);
MatchBuilder mb1 = new MatchBuilder();
ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(JoachimTheBig.class).build();
GeneralAugMatchNodesNodeTableFlow odlxxx1 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension1)).build();
Match match1 = mb1.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx1).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder mb2 = new org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder();
ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(JoachimTheTiny.class).build();
GeneralAugMatchNotifPacketIn odlxxx2 = new GeneralAugMatchNotifPacketInBuilder().setExtensionList(Collections.singletonList(extension2)).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match match2 = mb2.addAugmentation(GeneralAugMatchNotifPacketIn.class, odlxxx2).build();
Assert.assertEquals(JoachimTheBig.class, eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
Assert.assertEquals(JoachimTheTiny.class, eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder in project openflowplugin by opendaylight.
the class OF13MatchSerializerTest method buildIpv6FLabelMatch.
private static Match buildIpv6FLabelMatch(long labelValue, boolean hasMask, byte[] mask) {
MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Flabel.class);
entriesBuilder.setHasMask(hasMask);
Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue));
ipv6FlabelBuilder.setMask(mask);
ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
Match match = builder.build();
return match;
}
Aggregations