X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Fsal%2Fconvertor%2Fmatch%2FMatchConvertorV10Impl.java;h=0a5a4b7a3fc2f8e5a6b1de523920e208517eceb5;hb=2b799cb8e72f65158e9e01fab3223b09025ceceb;hp=4c45e06b0daa147865b41fb36894a1c2ea82dbbe;hpb=e6600559fd508ec7926dbceac9c6eb7c4b7a02f9;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java index 4c45e06b0d..0a5a4b7a3f 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -11,6 +11,8 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match; import java.math.BigInteger; import java.util.Iterator; +import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil; +import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; @@ -18,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match; @@ -26,8 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; /** * @@ -43,7 +46,7 @@ public class MatchConvertorV10Impl implements MatchConvertor { * The value 0xffff (OFP_VLAN_NONE) is used to indicate * that no VLAN ID is set for OF Flow. */ - private static final int OFP_VLAN_NONE = (int) 0xffff; + private static final Integer OFP_VLAN_NONE = 0xffff; /** * Method builds openflow 1.0 specific match (MatchV10) from MD-SAL match. @@ -100,8 +103,8 @@ public class MatchConvertorV10Impl implements MatchConvertor { if(l3Match != null){ if(l3Match instanceof Ipv4Match){ Ipv4Match ipv4 = (Ipv4Match)l3Match; - _tPSRC = convertL3Ipv4SrcMatch(matchBuilder, ipv4); - _tPDST = convertL3Ipv4DstMatch(matchBuilder, ipv4); + convertL3Ipv4SrcMatch(matchBuilder, ipv4); + convertL3Ipv4DstMatch(matchBuilder, ipv4); } } IpMatch ipMatch = match.getIpMatch(); @@ -120,6 +123,20 @@ public class MatchConvertorV10Impl implements MatchConvertor { _tPSRC = convertL4UdpSrcMatch(matchBuilder, udpMatch); _tPDST = convertL4UdpDstMatch(matchBuilder, udpMatch); } + } else { + Icmpv4Match icmpv4Match = match.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; + } + } } } @@ -195,7 +212,7 @@ public class MatchConvertorV10Impl implements MatchConvertor { private static boolean convertNwTos(final MatchV10Builder matchBuilder, final IpMatch ipMatch) { if (ipMatch.getIpDscp() != null) { - matchBuilder.setNwTos(ipMatch.getIpDscp().getValue()); + matchBuilder.setNwTos(ActionUtil.dscpToTos(ipMatch.getIpDscp().getValue())); return false; } return true; @@ -215,40 +232,38 @@ public class MatchConvertorV10Impl implements MatchConvertor { } /** + * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance. + * Wildcard value of the IP mask will be determined by Openflow java encoding library. * @param matchBuilder * @param ipv4 - * @return is wildCard */ - private static boolean convertL3Ipv4DstMatch(final MatchV10Builder matchBuilder, + private static void convertL3Ipv4DstMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) { if(ipv4.getIpv4Destination()!=null){ - Iterator addressParts = MatchConvertorImpl.PREFIX_SPLITTER.split(ipv4.getIpv4Destination().getValue()).iterator(); + Iterator addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Destination().getValue()).iterator(); Ipv4Address ipv4Address = new Ipv4Address(addressParts.next()); Integer prefix = buildPrefix(addressParts); matchBuilder.setNwDst(ipv4Address); matchBuilder.setNwDstMask(prefix.shortValue()); - return false; } - return true; } /** + * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance. + * Wildcard value of the IP mask will be determined by Openflow java encoding library. * @param matchBuilder * @param ipv4 - * @return is wildCard */ - private static boolean convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder, + private static void convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) { if(ipv4.getIpv4Source()!=null){ - Iterator addressParts = MatchConvertorImpl.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator(); + Iterator addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator(); Ipv4Address ipv4Address = new Ipv4Address(addressParts.next()); int prefix = buildPrefix(addressParts); matchBuilder.setNwSrc(ipv4Address); matchBuilder.setNwSrcMask((short) prefix); - return false; } - return true; } /**