Search in sources :

Example 26 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class OF10FlowModInputMessageFactoryTest method createMatch.

private static MatchV10 createMatch() {
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setInPort(58);
    matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
    matchBuilder.setDlVlan(18);
    matchBuilder.setDlVlanPcp((short) 5);
    matchBuilder.setDlType(42);
    matchBuilder.setNwTos((short) 4);
    matchBuilder.setNwProto((short) 7);
    matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
    matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
    matchBuilder.setTpSrc(6653);
    matchBuilder.setTpDst(6633);
    return matchBuilder.build();
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 27 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchV10Convertor method convert.

@Override
public MatchV10 convert(final Match source, final VersionConvertorData data) {
    MatchV10Builder matchBuilder = new MatchV10Builder();
    boolean dlDst = true;
    boolean dlSsc = true;
    boolean dlType = true;
    boolean dlVlan = true;
    boolean dlVlanPcp = true;
    boolean ipPort = true;
    boolean nwProto = true;
    boolean nwTos = true;
    boolean tpDst = true;
    boolean tpSrc = true;
    matchBuilder.setInPort(0);
    matchBuilder.setDlDst(ZERO_MAC);
    matchBuilder.setDlSrc(ZERO_MAC);
    matchBuilder.setDlType(0);
    matchBuilder.setDlVlan(OFP_VLAN_NONE);
    matchBuilder.setDlVlanPcp((short) 0);
    matchBuilder.setNwDst(ZERO_IPV4);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setNwSrc(ZERO_IPV4);
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwProto((short) 0);
    matchBuilder.setNwTos((short) 0);
    matchBuilder.setTpSrc(0);
    matchBuilder.setTpDst(0);
    if (source != null) {
        EthernetMatch ethernetMatch = source.getEthernetMatch();
        if (ethernetMatch != null) {
            dlDst = convertEthernetDlDst(matchBuilder, ethernetMatch);
            dlSsc = convertEthernetDlSrc(matchBuilder, ethernetMatch);
            dlType = convertEthernetDlType(matchBuilder, ethernetMatch);
        }
        VlanMatch vlanMatch = source.getVlanMatch();
        if (vlanMatch != null) {
            dlVlan = convertDlVlan(matchBuilder, vlanMatch);
            dlVlanPcp = convertDlVlanPcp(matchBuilder, vlanMatch);
        }
        NodeConnectorId inPort = source.getInPort();
        if (inPort != null) {
            ipPort = convertInPortMatch(matchBuilder, inPort);
        }
        Layer3Match l3Match = source.getLayer3Match();
        if (l3Match != null) {
            if (l3Match instanceof Ipv4Match) {
                Ipv4Match ipv4 = (Ipv4Match) l3Match;
                convertL3Ipv4SrcMatch(matchBuilder, ipv4);
                convertL3Ipv4DstMatch(matchBuilder, ipv4);
            }
        }
        IpMatch ipMatch = source.getIpMatch();
        if (ipMatch != null) {
            nwProto = convertNwProto(matchBuilder, ipMatch);
            nwTos = convertNwTos(matchBuilder, ipMatch);
        }
        Layer4Match layer4Match = source.getLayer4Match();
        if (layer4Match != null) {
            if (layer4Match instanceof TcpMatch) {
                TcpMatch tcpMatch = (TcpMatch) layer4Match;
                tpSrc = convertL4TpSrcMatch(matchBuilder, tcpMatch);
                tpDst = convertL4TpDstMatch(matchBuilder, tcpMatch);
            } else if (layer4Match instanceof UdpMatch) {
                UdpMatch udpMatch = (UdpMatch) layer4Match;
                tpSrc = convertL4UdpSrcMatch(matchBuilder, udpMatch);
                tpDst = convertL4UdpDstMatch(matchBuilder, udpMatch);
            }
        } else {
            Icmpv4Match icmpv4Match = source.getIcmpv4Match();
            if (icmpv4Match != null) {
                Short type = icmpv4Match.getIcmpv4Type();
                if (type != null) {
                    matchBuilder.setTpSrc(type.intValue());
                    tpSrc = false;
                }
                Short code = icmpv4Match.getIcmpv4Code();
                if (code != null) {
                    matchBuilder.setTpDst(code.intValue());
                    tpDst = false;
                }
            }
        }
    }
    FlowWildcardsV10 wildCards = new FlowWildcardsV10(dlDst, dlSsc, dlType, dlVlan, dlVlanPcp, ipPort, nwProto, nwTos, tpDst, tpSrc);
    matchBuilder.setWildcards(wildCards);
    return matchBuilder.build();
}
Also used : Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) Layer4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) VlanMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch)

Example 28 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchV10ResponseConvertorTest method testEmptyMatch.

/**
 * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test(expected = NullPointerException.class)
public void testEmptyMatch() {
    MatchV10Builder builder = new MatchV10Builder();
    MatchV10 match = builder.build();
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    final Match salMatch = convert(match, datapathIdConvertorData).build();
}
Also used : VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) BigInteger(java.math.BigInteger) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Test(org.junit.Test)

Example 29 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchV10ResponseConvertorTest method testMatchWithValuesUnset.

/**
 * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void testMatchWithValuesUnset() {
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
    builder.setNwProto((short) 17);
    builder.setTpSrc(2048);
    builder.setTpDst(4096);
    MatchV10 match = builder.build();
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    final Match salMatch = convert(match, datapathIdConvertorData).build();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
    Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
    UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong udp dst", 4096, udpMatch.getUdpDestinationPort().getValue().intValue());
    Assert.assertEquals("Wrong udp src", 2048, udpMatch.getUdpSourcePort().getValue().intValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) BigInteger(java.math.BigInteger) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Test(org.junit.Test)

Example 30 with MatchV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10 in project openflowplugin by opendaylight.

the class MatchV10ResponseConvertorTest method testWildcardedMatchWithNoValuesSet.

/**
 * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void testWildcardedMatchWithNoValuesSet() {
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    MatchV10 match = builder.build();
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(new BigInteger("42"));
    final Match salMatch = convert(match, datapathIdConvertorData).build();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
    Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) BigInteger(java.math.BigInteger) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Test(org.junit.Test)

Aggregations

MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)27 Test (org.junit.Test)16 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)16 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)15 BigInteger (java.math.BigInteger)12 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)10 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)10 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)10 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)10 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)9 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)9 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)9 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)9 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)7 ByteBuf (io.netty.buffer.ByteBuf)5 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)2