Search in sources :

Example 16 with FlowWildcardsV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.

the class MatchResponseConvertorTest method testFromOFMatchV10ToSALMatch.

/**
 * Test method for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testFromOFMatchV10ToSALMatch() {
    int[] vids = { // Match untagged frame.
    DL_VLAN_NONE, // Match packet with VLAN tag and VID equals the specified value.
    1, 20, 4095 };
    short[] dscps = { 0, 1, 20, 40, 62, 63 };
    FlowWildcardsV10Builder wcBuilder = new FlowWildcardsV10Builder();
    for (int vid : vids) {
        for (short dscp : dscps) {
            short tos = (short) (dscp << 2);
            MatchV10Builder builder = new MatchV10Builder();
            builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).setDlVlanPcp(VLAN_PCP).setDlType(ETHTYPE_IPV4).setInPort(IN_PORT.intValue()).setNwSrc(IPV4_SRC).setNwDst(IPV4_DST).setNwTos(tos);
            wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).setTpDst(true);
            if (vid == DL_VLAN_NONE) {
                wcBuilder.setDlVlanPcp(true);
            }
            FlowWildcardsV10 wc = wcBuilder.build();
            MatchV10 ofMatch = builder.setWildcards(wc).build();
            final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
            data.setDatapathId(DPID);
            Match match = convert(ofMatch, data).build();
            checkDefaultV10(match, wc, vid);
            IpMatch ipMatch = match.getIpMatch();
            assertEquals(null, ipMatch.getIpProtocol());
            assertEquals(dscp, ipMatch.getIpDscp().getValue().shortValue());
            assertEquals(null, ipMatch.getIpEcn());
            // Set all wildcard bits.
            wc = wcBuilder.setAll(true).build();
            ofMatch = builder.setWildcards(wc).build();
            match = convert(ofMatch, data).build();
            checkDefaultV10(match, wc, vid);
            assertEquals(null, match.getIpMatch());
        }
    }
}
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) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) VlanMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch) 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) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Test(org.junit.Test)

Example 17 with FlowWildcardsV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method createTableStats.

private static List<TableStats> createTableStats() {
    TableStatsBuilder builder = new TableStatsBuilder();
    builder.setTableId((short) 1);
    builder.setName("Table name");
    builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    builder.setMaxEntries(1L);
    builder.setActiveCount(1L);
    builder.setLookupCount(BigInteger.valueOf(1234L));
    builder.setMatchedCount(BigInteger.valueOf(1234L));
    List<TableStats> list = new ArrayList<>();
    list.add(builder.build());
    return list;
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) ArrayList(java.util.ArrayList) TableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder) TableStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)

Example 18 with FlowWildcardsV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.

the class OF10MatchSerializerTest method test.

/**
 * Testing correct serialization of ofp_match.
 */
@Test
public void test() {
    final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, true));
    builder.setNwSrcMask((short) 24);
    builder.setNwDstMask((short) 16);
    builder.setInPort(6653);
    builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
    builder.setDlVlan(128);
    builder.setDlVlanPcp((short) 2);
    builder.setDlType(15);
    builder.setNwTos((short) 14);
    builder.setNwProto((short) 85);
    builder.setNwSrc(new Ipv4Address("1.1.1.2"));
    builder.setNwDst(new Ipv4Address("32.16.8.1"));
    builder.setTpSrc(2048);
    builder.setTpDst(4096);
    MatchV10 match = builder.build();
    matchSerializer.serialize(match, out);
    Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt());
    Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    out.readBytes(dlSrc);
    Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    out.readBytes(dlDst);
    Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
    Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
    Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
    Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
    out.skipBytes(2);
    Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
    Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
    Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
    Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
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) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 19 with FlowWildcardsV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.

the class OF10MatchSerializerTest method test2.

/**
 * Testing correct serialization of ofp_match.
 */
@Test
public void test2() {
    final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    builder.setNwSrcMask((short) 0);
    builder.setNwDstMask((short) 0);
    builder.setInPort(6653);
    builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
    builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
    builder.setDlVlan(128);
    builder.setDlVlanPcp((short) 2);
    builder.setDlType(15);
    builder.setNwTos((short) 14);
    builder.setNwProto((short) 85);
    builder.setNwSrc(new Ipv4Address("1.1.1.2"));
    builder.setNwDst(new Ipv4Address("32.16.8.1"));
    builder.setTpSrc(2048);
    builder.setTpDst(4096);
    MatchV10 match = builder.build();
    matchSerializer.serialize(match, out);
    Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt());
    Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    out.readBytes(dlSrc);
    Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    out.readBytes(dlDst);
    Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort());
    Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort());
    Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte());
    Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte());
    out.skipBytes(2);
    Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt());
    Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt());
    Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort());
    Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort());
}
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) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 20 with FlowWildcardsV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10 in project openflowplugin by opendaylight.

the class MatchUtil method createEmptyV10Match.

public static MatchV10Builder createEmptyV10Match() {
    Short zeroShort = Short.valueOf("0");
    Integer zeroInteger = 0;
    MatchV10Builder matchV10Builder = new MatchV10Builder();
    matchV10Builder.setDlDst(ZERO_MAC_ADDRESS);
    matchV10Builder.setDlSrc(ZERO_MAC_ADDRESS);
    matchV10Builder.setDlType(zeroInteger);
    matchV10Builder.setDlVlan(zeroInteger);
    matchV10Builder.setDlVlanPcp(zeroShort);
    matchV10Builder.setInPort(zeroInteger);
    matchV10Builder.setNwDst(ZERO_IPV4_ADDRESS);
    matchV10Builder.setNwDstMask(zeroShort);
    matchV10Builder.setNwProto(zeroShort);
    matchV10Builder.setNwSrc(ZERO_IPV4_ADDRESS);
    matchV10Builder.setNwSrcMask(zeroShort);
    matchV10Builder.setNwTos(zeroShort);
    matchV10Builder.setTpDst(zeroInteger);
    matchV10Builder.setTpSrc(zeroInteger);
    FlowWildcardsV10 flowWildcardsV10 = new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true);
    matchV10Builder.setWildcards(flowWildcardsV10);
    return matchV10Builder;
}
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)

Aggregations

FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)28 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)23 Test (org.junit.Test)19 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)16 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)16 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)13 ByteBuf (io.netty.buffer.ByteBuf)10 BigInteger (java.math.BigInteger)10 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)10 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)10 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)9 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)9 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)8 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)8 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)8 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)8 ArrayList (java.util.ArrayList)3 VlanMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch)3 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)3 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)3