Search in sources :

Example 36 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MatchDeserializerInjector method injectDeserializers.

/**
 * Injects deserializers into provided
 * {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}.
 *
 * @param provider OpenflowJava deserializer extension provider
 */
static void injectDeserializers(final DeserializerExtensionProvider provider) {
    for (MatchPath path : MatchPath.values()) {
        final MatchDeserializer deserializer = new MatchDeserializer(path);
        provider.registerDeserializer(new MessageCodeMatchKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_LENGTH, Match.class, path), deserializer);
        // Inject new match entry serializers here using injector created by createInjector method
        final Function<Integer, Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>>> injector = createInjector(deserializer, EncodeConstants.OF13_VERSION_ID);
        // Wrapped injector that uses OPENFLOW_BASIC_CLASS
        final Function<Integer, Consumer<MatchEntryDeserializer>> basicInjector = injector.apply(OxmMatchConstants.OPENFLOW_BASIC_CLASS).apply(null);
        // Wrapped injector that uses EXPERIMENTER_CLASS
        final Function<Long, Function<Integer, Consumer<MatchEntryDeserializer>>> experInjector = injector.apply(OxmMatchConstants.EXPERIMENTER_CLASS);
        basicInjector.apply(OxmMatchConstants.ARP_OP).accept(new ArpOpEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ARP_SHA).accept(new ArpSourceHardwareAddressEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ARP_THA).accept(new ArpTargetHardwareAddressEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ARP_SPA).accept(new ArpSourceTransportAddressEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ARP_TPA).accept(new ArpTargetTransportAddressEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IN_PORT).accept(new InPortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IN_PHY_PORT).accept(new InPhyPortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.METADATA).accept(new MetadataEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ETH_DST).accept(new EthernetDestinationEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ETH_SRC).accept(new EthernetSourceEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ETH_TYPE).accept(new EthernetTypeEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.VLAN_PCP).accept(new VlanPcpEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.VLAN_VID).accept(new VlanVidEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IP_DSCP).accept(new IpDscpEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IP_ECN).accept(new IpEcnEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IP_PROTO).accept(new IpProtoEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.TCP_SRC).accept(new TcpSourcePortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.TCP_DST).accept(new TcpDestinationPortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.UDP_SRC).accept(new UdpSourcePortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.UDP_DST).accept(new UdpDestinationPortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.SCTP_SRC).accept(new SctpSourcePortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.SCTP_DST).accept(new SctpDestinationPortEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ICMPV4_CODE).accept(new Icmpv4CodeEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ICMPV4_TYPE).accept(new Icmpv4TypeEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ICMPV6_CODE).accept(new Icmpv6CodeEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.ICMPV6_TYPE).accept(new Icmpv6TypeEntryDeserializer());
        // TODO: How to differentiate between Ipv4 and Tunnel when both are serialized to same format?
        basicInjector.apply(OxmMatchConstants.IPV4_SRC).accept(new Ipv4SourceEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV4_DST).accept(new Ipv4DestinationEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_SRC).accept(new Ipv6SourceEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_DST).accept(new Ipv6DestinationEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_EXTHDR).accept(new Ipv6ExtHeaderEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_FLABEL).accept(new Ipv6FlabelEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_ND_SLL).accept(new Ipv6NdSllEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_ND_TLL).accept(new Ipv6NdTllEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.IPV6_ND_TARGET).accept(new Ipv6NdTargetEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.MPLS_LABEL).accept(new MplsLabelEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.MPLS_BOS).accept(new MplsBosEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.MPLS_TC).accept(new MplsTcEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.PBB_ISID).accept(new PbbEntryDeserializer());
        basicInjector.apply(OxmMatchConstants.TUNNEL_ID).accept(new TunnelIdEntryDeserializer());
        experInjector.apply(EncodeConstants.ONF_EXPERIMENTER_ID).apply(EncodeConstants.ONFOXM_ET_TCP_FLAGS).accept(new TcpFlagsEntryDeserializer());
    }
}
Also used : IpProtoEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpProtoEntryDeserializer) TunnelIdEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TunnelIdEntryDeserializer) Icmpv4CodeEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv4CodeEntryDeserializer) IpEcnEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpEcnEntryDeserializer) IpDscpEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.IpDscpEntryDeserializer) TcpSourcePortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpSourcePortEntryDeserializer) Consumer(java.util.function.Consumer) MatchDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MatchDeserializer) InPhyPortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.InPhyPortEntryDeserializer) SctpSourcePortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.SctpSourcePortEntryDeserializer) MplsTcEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsTcEntryDeserializer) VlanVidEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanVidEntryDeserializer) MplsBosEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsBosEntryDeserializer) Ipv6SourceEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6SourceEntryDeserializer) Ipv6ExtHeaderEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6ExtHeaderEntryDeserializer) Ipv6NdTllEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdTllEntryDeserializer) Ipv6NdSllEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdSllEntryDeserializer) UdpSourcePortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.UdpSourcePortEntryDeserializer) ArpSourceTransportAddressEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceTransportAddressEntryDeserializer) Icmpv6TypeEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv6TypeEntryDeserializer) Ipv4DestinationEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv4DestinationEntryDeserializer) SctpDestinationPortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.SctpDestinationPortEntryDeserializer) TcpDestinationPortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpDestinationPortEntryDeserializer) TcpFlagsEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.TcpFlagsEntryDeserializer) ArpTargetTransportAddressEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpTargetTransportAddressEntryDeserializer) MatchEntryDeserializer(org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MatchEntryDeserializer) PbbEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.PbbEntryDeserializer) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) VlanPcpEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.VlanPcpEntryDeserializer) Function(java.util.function.Function) MplsLabelEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MplsLabelEntryDeserializer) UdpDestinationPortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.UdpDestinationPortEntryDeserializer) Ipv6DestinationEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6DestinationEntryDeserializer) EthernetDestinationEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetDestinationEntryDeserializer) Ipv4SourceEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv4SourceEntryDeserializer) Icmpv4TypeEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv4TypeEntryDeserializer) MatchPath(org.opendaylight.openflowplugin.extension.api.path.MatchPath) ArpOpEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpOpEntryDeserializer) MetadataEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.MetadataEntryDeserializer) ArpTargetHardwareAddressEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpTargetHardwareAddressEntryDeserializer) Ipv6NdTargetEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6NdTargetEntryDeserializer) EthernetSourceEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetSourceEntryDeserializer) EthernetTypeEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.EthernetTypeEntryDeserializer) ArpSourceHardwareAddressEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.ArpSourceHardwareAddressEntryDeserializer) MessageCodeMatchKey(org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey) InPortEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.InPortEntryDeserializer) Ipv6FlabelEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Ipv6FlabelEntryDeserializer) Icmpv6CodeEntryDeserializer(org.opendaylight.openflowplugin.impl.protocol.deserialization.match.Icmpv6CodeEntryDeserializer)

Example 37 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MatchResponseConvertor2Test method testLayer3MatchArpWithMasks.

/**
 * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
 */
@Test
public void testLayer3MatchArpWithMasks() {
    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(ArpSpa.class);
    entriesBuilder.setHasMask(true);
    final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
    final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
    arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));
    arpSpaBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
    arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
    entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(ArpTpa.class);
    entriesBuilder.setHasMask(true);
    final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
    final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
    arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
    arpTpaBuilder.setMask(new byte[] { (byte) 255, (byte) 128, 0, 0 });
    arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
    entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(ArpSha.class);
    entriesBuilder.setHasMask(true);
    final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
    final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
    arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));
    arpShaBuilder.setMask(new byte[] { 0, 0, 1, 0, 4, 0 });
    arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
    entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);
    entriesBuilder.setHasMask(true);
    final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
    final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
    arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));
    arpThaBuilder.setMask(new byte[] { 1, 1, 1, 2, 2, 2 });
    arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
    entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
    entries.add(entriesBuilder.build());
    builder.setMatchEntry(entries);
    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(builder.build(), datapathIdConvertorData);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
    final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();
    Assert.assertEquals("Wrong arp spa", "10.0.0.3/24", arpMatch.getArpSourceTransportAddress().getValue());
    Assert.assertEquals("Wrong arp tpa", "10.0.0.0/9", arpMatch.getArpTargetTransportAddress().getValue());
    Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());
    Assert.assertEquals("Wrong arp sha mask", "00:00:01:00:04:00", arpMatch.getArpSourceHardwareAddress().getMask().getValue());
    Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());
    Assert.assertEquals("Wrong arp tha mask", "01:01:01:02:02:02", arpMatch.getArpTargetHardwareAddress().getMask().getValue());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) ArpSpaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder) ArpTpaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ArpShaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder) ArpThaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ArpThaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder) ArpShaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder) ArpTpaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder) ArpSpaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder) BigInteger(java.math.BigInteger) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

Example 38 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link 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());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) Ipv6DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder) Ipv6SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) SctpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder) Ipv6MatchArbitraryBitMask(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask) Ipv6SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

Example 39 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MatchResponseConvertor2Test method testEmptyMatch.

/**
 * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
 */
@Test(expected = NullPointerException.class)
public void testEmptyMatch() {
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    convert(new MatchBuilder().build(), datapathIdConvertorData);
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

Example 40 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link 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());
}
Also used : Ipv4SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) ArrayList(java.util.ArrayList) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) SctpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4MatchArbitraryBitMask(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) Ipv4DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder) Ipv4DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Ipv4SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)454 ByteBuf (io.netty.buffer.ByteBuf)138 ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)58 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)54 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)45 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)38 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)35 InetAddress (java.net.InetAddress)33 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)33 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)32 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)28 Inet4Address (java.net.Inet4Address)27 Inet6Address (java.net.Inet6Address)27 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)27 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)26 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)26