Merge "Fix codestyle"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / common / IpConversionUtil.java
index 1180766924e02bd72251d09983b7efb99ca99ddd..f5b8c44d5a5461def93e1c974564e9904bec45bf 100644 (file)
@@ -582,6 +582,17 @@ public final class IpConversionUtil {
         return sb.toString();
     }
 
+    /**
+     * Check if the supplied IPv6Address has any prefix
+     *
+     * @param ipv6Prefix Ipv6 prefix
+     * @return prefix if there is one, else null
+     */
+    public static Integer hasIpv6Prefix(final Ipv6Prefix ipv6Prefix) {
+        final int prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
+        return prefix < IPV6_ADDRESS_LENGTH ? prefix : null;
+    }
+
     private static int ipv6PrefixByteArrayOffset(final int mask) {
         if (mask < 0) {
             return 0;
@@ -721,7 +732,7 @@ public final class IpConversionUtil {
 
     public static final byte[] convertIpv6ArbitraryMaskToByteArray(final Ipv6ArbitraryMask mask) {
         String maskValue;
-        if (mask.getValue() != null) {
+        if (mask != null && mask.getValue() != null) {
             maskValue  = mask.getValue();
         } else {
             maskValue = DEFAULT_IPV6_ARBITRARY_BITMASK;