Search in sources :

Example 16 with Wildcards

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFactoryTest method testFlow.

/**
 * Testing OF10StatsRequestInputFactory (Flow) for correct serialization.
 */
@Test
public void testFlow() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPFLOW);
    builder.setFlags(new MultipartRequestFlags(false));
    final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
    final MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
    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);
    flowBuilder.setMatchV10(matchBuilder.build());
    flowBuilder.setTableId((short) 1);
    flowBuilder.setOutPort(42L);
    caseBuilder.setMultipartRequestFlow(flowBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 56);
    Assert.assertEquals("Wrong type", 1, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt());
    Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    out.readBytes(dlSrc);
    Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    out.readBytes(dlDst);
    Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort());
    Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort());
    Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte());
    Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte());
    out.skipBytes(2);
    Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt());
    Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt());
    Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort());
    Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort());
    Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort());
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
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) MultipartRequestFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder) MultipartRequestFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder) 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) 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 17 with Wildcards

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFactoryTest method testAggregate.

/**
 * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization.
 */
@Test
public void testAggregate() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setType(MultipartType.OFPMPAGGREGATE);
    builder.setFlags(new MultipartRequestFlags(false));
    final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder();
    final MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder();
    MatchV10Builder matchBuilder = new MatchV10Builder();
    matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false));
    matchBuilder.setNwSrcMask((short) 32);
    matchBuilder.setNwDstMask((short) 32);
    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);
    flowBuilder.setMatchV10(matchBuilder.build());
    flowBuilder.setTableId((short) 42);
    flowBuilder.setOutPort(6653L);
    caseBuilder.setMultipartRequestFlow(flowBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV10(out, (byte) 16, 56);
    Assert.assertEquals("Wrong type", 2, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt());
    Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    out.readBytes(dlSrc);
    Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    out.readBytes(dlDst);
    Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort());
    Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort());
    Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte());
    Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte());
    out.skipBytes(2);
    Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt());
    Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt());
    Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort());
    Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort());
    Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte());
    out.skipBytes(1);
    Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort());
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
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) MultipartRequestFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder) MultipartRequestFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder) 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) 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 18 with Wildcards

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards 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 19 with Wildcards

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards in project openflowplugin by opendaylight.

the class OpenflowpluginTableFeaturesTestCommandProvider method createTestTableFeatures.

private TableFeaturesBuilder createTestTableFeatures(String tableFeatureTypeArg) {
    String tableFeatureType = tableFeatureTypeArg;
    if (tableFeatureType == null) {
        tableFeatureType = "t1";
    }
    final TableFeaturesBuilder tableFeature = new TableFeaturesBuilder();
    // Sample data , committing to DataStore
    if (!tableFeatureType.equals("t1")) {
        tableFeature.setTableId((short) 0);
        tableFeature.setName("Table 0");
        tableFeature.setMetadataMatch(BigInteger.valueOf(10));
        tableFeature.setMetadataWrite(BigInteger.valueOf(10));
        tableFeature.setMaxEntries(10000L);
        tableFeature.setConfig(new TableConfig(false));
        List<TableFeatureProperties> properties = new ArrayList<>();
        switch(tableFeatureType) {
            case "t2":
                // To set the ApplyActionsMiss
                properties.add(createApplyActionsMissTblFeatureProp().build());
                break;
            case "t3":
                // To set the Next Table
                properties.add(createNextTblFeatureProp().build());
                break;
            case "t4":
                // To set the Next Table Miss
                properties.add(createNextTableMissTblFeatureProp().build());
                break;
            case "t5":
                // To set the ApplyActions
                properties.add(createApplyActionsTblFeatureProp().build());
                break;
            case "t6":
                // To set the instructions
                properties.add(createInstructionsTblFeatureProp().build());
                break;
            case "t7":
                // To set the instructions miss
                properties.add(createInstructionsMissTblFeatureProp().build());
                break;
            case "t8":
                // To set the write actions
                properties.add(createWriteActionsTblFeatureProp().build());
                break;
            case "t9":
                // To set the write actions miss
                properties.add(createWriteActionsMissTblFeatureProp().build());
                break;
            case "t10":
                // To set the match field
                properties.add(createMatchFieldTblFeatureProp().build());
                break;
            case "t11":
                // To set the write set-field
                properties.add(createWriteSetFieldTblFeatureProp().build());
                break;
            case "t12":
                // To set the write set-field miss
                properties.add(createWriteSetFieldMissTblFeatureProp().build());
                break;
            case "t13":
                // To set the apply set field
                properties.add(createApplySetFieldTblFeatureProp().build());
                break;
            case "t14":
                // To set the apply set field miss
                properties.add(createApplySetFieldMissTblFeatureProp().build());
                break;
            case "t15":
                // To set the wildcards set field match
                properties.add(createWildCardsTblFeatureProp().build());
                break;
            default:
                break;
        }
        TablePropertiesBuilder propertyBld = new TablePropertiesBuilder();
        propertyBld.setTableFeatureProperties(properties);
        tableFeature.setTableProperties(propertyBld.build());
    }
    return tableFeature;
}
Also used : TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties) ArrayList(java.util.ArrayList) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig) TablePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder)

Aggregations

Test (org.junit.Test)13 ByteBuf (io.netty.buffer.ByteBuf)11 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)10 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 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)8 ArrayList (java.util.ArrayList)6 BigInteger (java.math.BigInteger)5 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)4 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)4 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 ApplySetfield (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)2 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)2 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)2 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)2 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)2 Wildcards (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards)2