From 4b8344372863771a497b5ba00c57c6a9030920ab Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 13 Aug 2014 13:51:22 +0200 Subject: Fix broken parsing and output of IPv6 Routes --HG-- extra : rebase_source : 3ffb8db4e128c62426e18c79d5cc6876136bf3bf --- main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java index 31290d8a..cb662944 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java +++ b/main/src/main/java/de/blinkt/openvpn/core/NetworkSpace.java @@ -76,8 +76,8 @@ public class NetworkSpace { netAddress = BigInteger.ZERO; for (byte b : address.getAddress()) { - s -= 16; - netAddress = netAddress.add(BigInteger.valueOf(b).shiftLeft(s)); + s -= 8; + netAddress = netAddress.add(BigInteger.valueOf((b & 0xFF)).shiftLeft(s)); } } @@ -152,12 +152,12 @@ public class NetworkSpace { String getIPv6Address() { if (BuildConfig.DEBUG) Assert.assertTrue (!isV4); BigInteger r = netAddress; - if (r.longValue() == 0) + if (r.compareTo(BigInteger.ZERO)==0 && networkMask==0) return "::"; Vector parts = new Vector(); while (r.compareTo(BigInteger.ZERO) == 1) { - parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(256)).longValue())); + parts.add(0, String.format(Locale.US, "%x", r.mod(BigInteger.valueOf(0x10000)).longValue())); r = r.shiftRight(16); } -- cgit v1.2.3