* 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
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
public static final String UDP = "udp";
public static final String TCP = "tcp";
public static final String ICMP = "icmp";
+ public static final String ICMPv6 = "icmpv6";
private NeutronUtils() {
throw new UnsupportedOperationException("Cannot create an instance.");
Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE, SecRuleEntityDecoder.getProtocol(secRule));
}
+ @Test
+ public final void testGetProtocol_numValue() {
+ secRule.setSecurityRuleProtocol("199");
+ Assert.assertEquals(Long.valueOf(199) , SecRuleEntityDecoder.getProtocol(secRule));
+ }
+
@Test
public final void testGetProtocol_protoNull() {
secRule.setSecurityRuleProtocol(null);