Search in sources :

Example 71 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.

the class PacketReceivedTranslator method getPacketInMatch.

@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
    datapathIdConvertorData.setDatapathId(datapathId);
    final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
    final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
    final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
    if (matchExtensionWrap != null) {
        matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
    }
    return matchBuilder.build();
}
Also used : PacketInUtil(org.opendaylight.openflowplugin.impl.util.PacketInUtil) ConvertorExecutor(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor) MatchPath(org.opendaylight.openflowplugin.extension.api.path.MatchPath) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) MatchExtensionHelper(org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) PacketInMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage) AugmentTuple(org.opendaylight.openflowplugin.extension.api.AugmentTuple) Optional(java.util.Optional) BigInteger(java.math.BigInteger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) NodeConnectorRefToPortTranslator(org.opendaylight.openflowplugin.impl.util.NodeConnectorRefToPortTranslator) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 72 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.

the class UdpDestinationPortEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int tcp = 10;
    final Match sctpMatch = new MatchBuilder().setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(new PortNumber(tcp)).build()).build();
    assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
}
Also used : UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 73 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.

the class InPortEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int port = 42;
    final Match match = new MatchBuilder().setInPort(new NodeConnectorId("openflow:1:" + port)).build();
    assertMatch(match, false, (out) -> assertEquals(out.readUnsignedInt(), port));
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Example 74 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.

the class IpEcnEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final short ecn = (short) 58;
    final Match match = new MatchBuilder().setIpMatch(new IpMatchBuilder().setIpEcn(ecn).build()).build();
    assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), ecn));
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Example 75 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.

the class Ipv4ArbitraryBitMaskDestinationEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final Ipv4Address ipv4Address = new Ipv4Address("192.168.10.0");
    final DottedQuad ipv4mask = new DottedQuad("255.255.255.0");
    final Match ipv4abmMatch = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).setIpv4DestinationArbitraryBitmask(ipv4mask).build()).build();
    assertMatch(ipv4abmMatch, true, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
        byte[] mask = new byte[4];
        out.readBytes(mask);
        assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
    });
    final Match ipv4abmMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).build()).build();
    assertMatch(ipv4abmMatchNoMask, false, (out) -> {
        byte[] address = new byte[4];
        out.readBytes(address);
        assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
    });
}
Also used : Ipv4MatchArbitraryBitMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder) DottedQuad(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Aggregations

MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)220 Test (org.junit.Test)135 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)90 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)84 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)80 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)69 ArrayList (java.util.ArrayList)65 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)63 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)56 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)55 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)54 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)53 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)52 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)51 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)51 BigInteger (java.math.BigInteger)46 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)44 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)42 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)40