[ONOS-8036] BGP-LS has only partial support for IPv6

- Removed hard-coded Ipv4Address and replaced with the generic
IpAddress wherever necessary
- Added support of AFI = 2 (IPv6) in MPReachNlri and MPUnreachNlri
- Added a new config parameter for IPv6 in BGP Config. This allows
AFI = 2 to be sent in BGP Open messages
- Skipped TLV 1170 and 1173, which were causing exceptions

Change-Id: I76e69021b1d2687754bbf700681070051e347942
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java
index 3764842..21ab244 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Validation.java
@@ -41,6 +41,9 @@
     public static final byte THIRD_BIT = 0x20;
     public static final byte FOURTH_BIT = (byte) 0x10;
     public static final byte IPV4_SIZE = 4;
+    public static final byte IPV6_SIZE = 16;
+    public static final int INET4_LENGTH = 32;
+
     private boolean firstBit;
     private boolean secondBit;
     private boolean thirdBit;
@@ -227,10 +230,20 @@
      * @return object of IpPrefix
      */
     public static IpPrefix bytesToPrefix(byte[] value, int length) {
-        if (value.length != IPV4_SIZE) {
-            value = Arrays.copyOf(value, IPV4_SIZE);
+        if (length <= INET4_LENGTH) {
+            //Treat like IPv4 address
+            if (value.length != IPV4_SIZE) {
+                value = Arrays.copyOf(value, IPV4_SIZE);
+            }
+            IpPrefix ipPrefix = IpPrefix.valueOf(IpAddress.Version.INET, value, length);
+            return ipPrefix;
+        } else {
+            //Treat this like IPv6 address
+            if (value.length != IPV6_SIZE) {
+                value = Arrays.copyOf(value, IPV6_SIZE);
+            }
+            IpPrefix ipPrefix = IpPrefix.valueOf(IpAddress.Version.INET6, value, length);
+            return ipPrefix;
         }
-        IpPrefix ipPrefix = IpPrefix.valueOf(IpAddress.Version.INET, value, length);
-        return ipPrefix;
     }
 }