Bug 5483 - added support for num values in rules
[groupbasedpolicy.git] / neutron-mapper / src / main / java / org / opendaylight / groupbasedpolicy / neutron / mapper / mapping / rule / SecRuleEntityDecoder.java
index bfda7e364d52eea7586773412a1845ea6b5b91cb..e9d42f469d3f0c138fc7c548b87f4c0836ca9b01 100755 (executable)
@@ -237,7 +237,7 @@ public class SecRuleEntityDecoder {
      *         empty; Otherwise protocol number\r
      * @throws IllegalArgumentException if return value of\r
      *         {@link NeutronSecurityRule#getSecurityRuleProtocol()} is not empty/null and is other\r
-     *         than "tcp", "udp", "icmp"\r
+     *         than "tcp", "udp", "icmp", "icmpv6" or string values that can be decoded to {@link Short}.\r
      */\r
     public static Long getProtocol(NeutronSecurityRule secRule) {\r
         String protocol = secRule.getSecurityRuleProtocol();\r
@@ -253,6 +253,16 @@ public class SecRuleEntityDecoder {
         if (NeutronUtils.ICMP.equals(protocol)) {\r
             return IpProtoClassifierDefinition.ICMP_VALUE;\r
         }\r
-        throw new IllegalArgumentException("Protocol " + protocol + " is not supported.");\r
+        if (NeutronUtils.ICMPv6.equals(protocol)) {\r
+            return IpProtoClassifierDefinition.ICMPv6_VALUE;\r
+        }\r
+        Long protocolNum;\r
+        try {\r
+            protocolNum = Long.valueOf(protocol);\r
+        } catch (NumberFormatException e) {\r
+            throw new IllegalArgumentException("Neutron Security Rule Protocol value " + protocol\r
+                    + " is not supported.");\r
+        }\r
+        return protocolNum;\r
     }\r
 }\r