Search in sources :

Example 11 with FlowWildcardsV10

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

the class OF10StatsRequestAggregateTest method test.

/**
 * Tests {@link OF10StatsRequestInputFactory} for correct serialization.
 */
@Test
public void test() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPAGGREGATE);
    builder.setFlags(new MultipartRequestFlags(false));
    final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder();
    final MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder();
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
    matchBuilder.setNwSrcMask((short) 8);
    matchBuilder.setNwDstMask((short) 16);
    matchBuilder.setInPort(51);
    matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05"));
    matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00"));
    matchBuilder.setDlVlan(52);
    matchBuilder.setDlVlanPcp((short) 53);
    matchBuilder.setDlType(54);
    matchBuilder.setNwTos((short) 55);
    matchBuilder.setNwProto((short) 56);
    matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1"));
    matchBuilder.setNwDst(new Ipv4Address("10.0.0.2"));
    matchBuilder.setTpSrc(57);
    matchBuilder.setTpDst(58);
    aggBuilder.setMatchV10(matchBuilder.build());
    aggBuilder.setTableId((short) 5);
    aggBuilder.setOutPort(42L);
    caseBuilder.setMultipartRequestAggregate(aggBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    statsFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 56);
    Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    // skip match check
    out.skipBytes(40);
    Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort());
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MultipartRequestAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartRequestAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 12 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 testTable.

/**
 * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization.
 */
@Test
public void testTable() {
    ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTable message = messageCase.getMultipartReplyTable();
    Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());
    Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName());
    Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false), message.getTableStats().get(0).getWildcards());
    Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue());
    Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue());
    Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue());
    Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());
    Assert.assertEquals("Wrong lookupCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getTableStats().get(0).getLookupCount());
    Assert.assertEquals("Wrong matchedCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }), message.getTableStats().get(0).getMatchedCount());
    Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MultipartReplyTable(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 13 with FlowWildcardsV10

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

the class MatchUtilTest method expectedV10Match.

private MatchV10Builder expectedV10Match() {
    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)

Example 14 with FlowWildcardsV10

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

the class MatchConvertorV10Test method testConvertIcmpv4.

@Test
public void testConvertIcmpv4() {
    MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
    Match match = matchBuilder.build();
    Optional<MatchV10> matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    MatchV10 matchV10 = matchV10Optional.get();
    final Integer zero = 0;
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(zero, matchV10.getTpSrc());
    assertEquals(zero, matchV10.getTpDst());
    boolean wcTpSrc = true;
    boolean wcTpDst = true;
    FlowWildcardsV10 wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    assertEquals(wc, matchV10.getWildcards());
    // Specify ICMP type only.
    Integer icmpType = 55;
    Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue());
    wcTpSrc = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(icmpType, matchV10.getTpSrc());
    assertEquals(zero, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
    // Specify ICMP code only.
    Integer icmpCode = 31;
    icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue());
    wcTpSrc = true;
    wcTpDst = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(zero, matchV10.getTpSrc());
    assertEquals(icmpCode, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
    // Specify both ICMP type and code.
    icmpType = 11;
    icmpCode = 22;
    icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue()).setIcmpv4Code(icmpCode.shortValue());
    wcTpSrc = false;
    wcTpDst = false;
    wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
    match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
    matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
    matchV10 = matchV10Optional.get();
    assertEquals(ZERO_MAC, matchV10.getDlDst());
    assertEquals(FF_MAC, matchV10.getDlSrc());
    assertEquals(0, matchV10.getDlType().intValue());
    assertEquals(0xffff, matchV10.getDlVlan().intValue());
    assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
    assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
    assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
    assertEquals(0, matchV10.getNwTos().shortValue());
    assertEquals(icmpType, matchV10.getTpSrc());
    assertEquals(icmpCode, matchV10.getTpDst());
    assertEquals(wc, matchV10.getWildcards());
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) Icmpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder) VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) 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) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Example 15 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 checkDefaultV10.

private static void checkDefaultV10(final Match match, final FlowWildcardsV10 wc, final int vid) {
    EthernetMatch ethMatch = match.getEthernetMatch();
    if (wc.isDLSRC()) {
        if (ethMatch != null) {
            assertEquals(null, ethMatch.getEthernetSource());
        }
    } else {
        assertEquals(MAC_SRC, ethMatch.getEthernetSource().getAddress());
    }
    if (ethMatch != null) {
        if (wc.isDLDST()) {
            assertEquals(null, ethMatch.getEthernetDestination());
        } else {
            assertNotEquals(null, ethMatch.getEthernetDestination());
            assertEquals(MAC_DST, ethMatch.getEthernetDestination().getAddress());
        }
    }
    if (wc.isDLTYPE()) {
        if (ethMatch != null) {
            assertEquals(null, ethMatch.getEthernetType());
        }
        assertEquals(null, match.getLayer3Match());
    } else {
        assert ethMatch != null;
        assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().getValue().intValue());
        Ipv4Match ipv4Match = (Ipv4Match) match.getLayer3Match();
        assertEquals(IPV4_SRC.getValue() + "/32", ipv4Match.getIpv4Source().getValue());
        assertEquals(IPV4_DST.getValue() + "/32", ipv4Match.getIpv4Destination().getValue());
    }
    VlanMatch vlanMatch = match.getVlanMatch();
    if (wc.isDLVLAN()) {
        assertEquals(null, vlanMatch);
    } else {
        int expectedVid;
        Boolean expectedCfi;
        if (vid == DL_VLAN_NONE) {
            expectedVid = 0;
            expectedCfi = Boolean.FALSE;
        } else {
            expectedVid = vid;
            expectedCfi = Boolean.TRUE;
        }
        assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
        assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
        if (wc.isDLVLANPCP()) {
            assertEquals(null, vlanMatch.getVlanPcp());
        } else {
            assertEquals(VLAN_PCP, vlanMatch.getVlanPcp().getValue().shortValue());
        }
    }
}
Also used : EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) VlanMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)

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