Search in sources :

Example 1 with MatchV10Builder

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

the class OF10MatchDeserializer method deserialize.

@Override
public MatchV10 deserialize(final ByteBuf input) {
    MatchV10Builder builder = new MatchV10Builder();
    long wildcards = input.readUnsignedInt();
    builder.setWildcards(createWildcards(wildcards));
    builder.setNwSrcMask(decodeNwSrcMask(wildcards));
    builder.setNwDstMask(decodeNwDstMask(wildcards));
    builder.setInPort(input.readUnsignedShort());
    builder.setDlSrc(ByteBufUtils.readIetfMacAddress(input));
    builder.setDlDst(ByteBufUtils.readIetfMacAddress(input));
    builder.setDlVlan(input.readUnsignedShort());
    builder.setDlVlanPcp(input.readUnsignedByte());
    input.skipBytes(PADDING_IN_MATCH);
    builder.setDlType(input.readUnsignedShort());
    builder.setNwTos(input.readUnsignedByte());
    builder.setNwProto(input.readUnsignedByte());
    input.skipBytes(PADDING_IN_MATCH_2);
    builder.setNwSrc(ByteBufUtils.readIetfIpv4Address(input));
    builder.setNwDst(ByteBufUtils.readIetfIpv4Address(input));
    builder.setTpSrc(input.readUnsignedShort());
    builder.setTpDst(input.readUnsignedShort());
    return builder.build();
}
Also used : MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)

Example 2 with MatchV10Builder

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

the class MultipartRequestInputFactory method makeDefaultMultiLayerBody.

private static MultipartRequestBody makeDefaultMultiLayerBody(@Nonnull final MultipartType type, final short version) {
    switch(type) {
        case OFPMPDESC:
            return new MultipartRequestDescCaseBuilder().build();
        case OFPMPFLOW:
            final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
            MultipartRequestFlowBuilder multipartRequestFlowBuilder = new MultipartRequestFlowBuilder();
            multipartRequestFlowBuilder.setTableId(OFConstants.OFPTT_ALL);
            multipartRequestFlowBuilder.setOutPort(OFConstants.OFPP_ANY);
            multipartRequestFlowBuilder.setOutGroup(OFConstants.OFPG_ANY);
            multipartRequestFlowBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
            multipartRequestFlowBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
            switch(version) {
                case OFConstants.OFP_VERSION_1_0:
                    MatchV10Builder matchV10Builder = MatchUtil.createEmptyV10Match();
                    multipartRequestFlowBuilder.setMatchV10(matchV10Builder.build());
                    break;
                case OFConstants.OFP_VERSION_1_3:
                    multipartRequestFlowBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
                    break;
                default:
                    throw new IllegalArgumentException("Unknown version " + version);
            }
            multipartRequestFlowCaseBuilder.setMultipartRequestFlow(multipartRequestFlowBuilder.build());
            return multipartRequestFlowCaseBuilder.build();
        case OFPMPAGGREGATE:
            return new MultipartRequestAggregateCaseBuilder().build();
        case OFPMPTABLE:
            return new MultipartRequestTableCaseBuilder().build();
        case OFPMPPORTSTATS:
            MultipartRequestPortStatsCaseBuilder multipartRequestPortStatsCaseBuilder = new MultipartRequestPortStatsCaseBuilder();
            MultipartRequestPortStatsBuilder multipartRequestPortStatsBuilder = new MultipartRequestPortStatsBuilder();
            multipartRequestPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
            multipartRequestPortStatsCaseBuilder.setMultipartRequestPortStats(multipartRequestPortStatsBuilder.build());
            return multipartRequestPortStatsCaseBuilder.build();
        case OFPMPQUEUE:
            MultipartRequestQueueCaseBuilder multipartRequestQueueCaseBuilder = new MultipartRequestQueueCaseBuilder();
            MultipartRequestQueueBuilder multipartRequestQueueBuilder = new MultipartRequestQueueBuilder();
            multipartRequestQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
            multipartRequestQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
            multipartRequestQueueCaseBuilder.setMultipartRequestQueue(multipartRequestQueueBuilder.build());
            return multipartRequestQueueCaseBuilder.build();
        case OFPMPGROUP:
            MultipartRequestGroupCaseBuilder multipartRequestGroupCaseBuilder = new MultipartRequestGroupCaseBuilder();
            MultipartRequestGroupBuilder multipartRequestGroupBuilder = new MultipartRequestGroupBuilder();
            GroupId groupId = new GroupId(OFConstants.OFPG_ALL);
            multipartRequestGroupBuilder.setGroupId(groupId);
            multipartRequestGroupCaseBuilder.setMultipartRequestGroup(multipartRequestGroupBuilder.build());
            return multipartRequestGroupCaseBuilder.build();
        case OFPMPGROUPDESC:
            return new MultipartRequestGroupDescCaseBuilder().build();
        case OFPMPGROUPFEATURES:
            return new MultipartRequestGroupFeaturesCaseBuilder().build();
        case OFPMPMETER:
            MultipartRequestMeterCaseBuilder multipartRequestMeterCaseBuilder = new MultipartRequestMeterCaseBuilder();
            MultipartRequestMeterBuilder multipartRequestMeterBuilder = new MultipartRequestMeterBuilder();
            MeterId meterId = new MeterId(OFConstants.OFPM_ALL);
            multipartRequestMeterBuilder.setMeterId(meterId);
            multipartRequestMeterCaseBuilder.setMultipartRequestMeter(multipartRequestMeterBuilder.build());
            return multipartRequestMeterCaseBuilder.build();
        case OFPMPMETERCONFIG:
            MultipartRequestMeterConfigCaseBuilder multipartRequestMeterConfigCaseBuilder = new MultipartRequestMeterConfigCaseBuilder();
            MultipartRequestMeterConfigBuilder multipartRequestMeterConfigBuilder = new MultipartRequestMeterConfigBuilder();
            MeterId configMeterId = new MeterId(OFConstants.OFPM_ALL);
            multipartRequestMeterConfigBuilder.setMeterId(configMeterId);
            multipartRequestMeterConfigCaseBuilder.setMultipartRequestMeterConfig(multipartRequestMeterConfigBuilder.build());
            return multipartRequestMeterConfigCaseBuilder.build();
        case OFPMPMETERFEATURES:
            return new MultipartRequestMeterFeaturesCaseBuilder().build();
        case OFPMPTABLEFEATURES:
            MultipartRequestTableFeaturesCaseBuilder tableFeaturesCaseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
            tableFeaturesCaseBuilder.setMultipartRequestTableFeatures(new MultipartRequestTableFeaturesBuilder().build());
            return tableFeaturesCaseBuilder.build();
        case OFPMPPORTDESC:
            return new MultipartRequestPortDescCaseBuilder().build();
        case OFPMPEXPERIMENTER:
            return new MultipartRequestExperimenterCaseBuilder().build();
        default:
            throw new IllegalArgumentException("Unknown MultipartType " + type);
    }
}
Also used : MultipartRequestPortStatsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder) MultipartRequestMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder) MultipartRequestMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder) MultipartRequestQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder) MultipartRequestPortDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MultipartRequestQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder) 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) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) MultipartRequestGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder) MultipartRequestAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder) MultipartRequestDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder) MultipartRequestMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder) MultipartRequestGroupDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) MultipartRequestGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder) MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) MultipartRequestMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder) MultipartRequestMeterFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder) MultipartRequestGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) MultipartRequestPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder)

Example 3 with MatchV10Builder

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

the class MatchV10ResponseConvertorTest method testUdpMatch.

/**
 * UDP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void testUdpMatch() {
    // TP_SRC, TP_DST are wildcarded.
    // NW_PROTO is not wildcarded but null.
    Long dlType = 0x800L;
    FlowWildcardsV10 wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, true);
    MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
    MatchV10 match = builder.build();
    BigInteger dpid = BigInteger.valueOf(12345L);
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(dpid);
    Match salMatch = convert(match, datapathIdConvertorData).build();
    EthernetMatch etherMatch = salMatch.getEthernetMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify UDP protocol.
    Short ipProto = 17;
    match = builder.setNwProto(ipProto).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    IpMatch ipMatch = salMatch.getIpMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // TP_SRC is not wildcarded but null.
    wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, false);
    match = builder.setWildcards(wc).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify UDP source port.
    Integer srcPort = 60000;
    match = builder.setTpSrc(srcPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong UDP src", srcPort, udpMatch.getUdpSourcePort().getValue());
    Assert.assertEquals("Wrong UDP dst", null, udpMatch.getUdpDestinationPort());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // TP_DST is not wildcarded but null.
    wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, false, false);
    match = builder.setWildcards(wc).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    udpMatch = (UdpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong UDP src", srcPort, udpMatch.getUdpSourcePort().getValue());
    Assert.assertEquals("Wrong UDP dst", null, udpMatch.getUdpDestinationPort());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify UDP destination port only.
    Integer dstPort = 6653;
    match = builder.setTpSrc(null).setTpDst(dstPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    udpMatch = (UdpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong UDP src", null, udpMatch.getUdpSourcePort());
    Assert.assertEquals("Wrong UDP dst", dstPort, udpMatch.getUdpDestinationPort().getValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify both source and destination port.
    srcPort = 32767;
    dstPort = 9999;
    match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    udpMatch = (UdpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong UDP src", srcPort, udpMatch.getUdpSourcePort().getValue());
    Assert.assertEquals("Wrong UDP dst", dstPort, udpMatch.getUdpDestinationPort().getValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
Also used : BigInteger(java.math.BigInteger) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) 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) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) 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 4 with MatchV10Builder

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

the class MatchV10ResponseConvertorTest method testTcpMatch.

/**
 * TCP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void testTcpMatch() {
    // TP_SRC, TP_DST are wildcarded.
    // NW_PROTO is not wildcarded but null.
    Long dlType = 0x800L;
    FlowWildcardsV10 wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, true);
    MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
    MatchV10 match = builder.build();
    BigInteger dpid = BigInteger.valueOf(12345L);
    final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    datapathIdConvertorData.setDatapathId(dpid);
    Match salMatch = convert(match, datapathIdConvertorData).build();
    EthernetMatch etherMatch = salMatch.getEthernetMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify TCP protocol.
    Short ipProto = 6;
    match = builder.setNwProto(ipProto).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    IpMatch ipMatch = salMatch.getIpMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // TP_SRC is not wildcarded but null.
    wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, true, false);
    match = builder.setWildcards(wc).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify TCP source port.
    Integer srcPort = 60000;
    match = builder.setTpSrc(srcPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
    Assert.assertEquals("Wrong TCP dst", null, tcpMatch.getTcpDestinationPort());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // TP_DST is not wildcarded but null.
    wc = new FlowWildcardsV10(true, true, false, true, true, true, false, true, false, false);
    match = builder.setWildcards(wc).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    tcpMatch = (TcpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
    Assert.assertEquals("Wrong TCP dst", null, tcpMatch.getTcpDestinationPort());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify TCP destination port only.
    Integer dstPort = 6653;
    match = builder.setTpSrc(null).setTpDst(dstPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    tcpMatch = (TcpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong TCP src", null, tcpMatch.getTcpSourcePort());
    Assert.assertEquals("Wrong TCP dst", dstPort, tcpMatch.getTcpDestinationPort().getValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
    // Specify both source and destination port.
    srcPort = 32767;
    dstPort = 9999;
    match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
    salMatch = convert(match, datapathIdConvertorData).build();
    etherMatch = salMatch.getEthernetMatch();
    ipMatch = salMatch.getIpMatch();
    tcpMatch = (TcpMatch) salMatch.getLayer4Match();
    Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
    Assert.assertEquals("Wrong dl src", null, etherMatch.getEthernetSource());
    Assert.assertEquals("Wrong dl dst", null, etherMatch.getEthernetDestination());
    Assert.assertEquals("Wrong dl type", dlType, etherMatch.getEthernetType().getType().getValue());
    Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
    Assert.assertEquals("Wrong ip protocol", ipProto, ipMatch.getIpProtocol());
    Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
    Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
    Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
    Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
    Assert.assertEquals("Wrong TCP src", srcPort, tcpMatch.getTcpSourcePort().getValue());
    Assert.assertEquals("Wrong TCP dst", dstPort, tcpMatch.getTcpDestinationPort().getValue());
    Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
}
Also used : BigInteger(java.math.BigInteger) 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) 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) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) 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 5 with MatchV10Builder

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

the class MatchV10ResponseConvertorTest method testWildcardedMatch.

/**
 * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
 */
@Test
public void testWildcardedMatch() {
    MatchV10Builder builder = new MatchV10Builder();
    builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, 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) 6);
    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();
    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) 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) 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

MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)27 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)23 Test (org.junit.Test)17 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)14 MatchV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)12 BigInteger (java.math.BigInteger)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 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)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 ByteBuf (io.netty.buffer.ByteBuf)7 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)5 MultipartRequestAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder)3 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)3 MultipartRequestAggregateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder)3