diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-18 14:11:37 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-18 14:11:37 +0200 |
commit | 40eb17c3c472bf088568abe7082427f1ab891399 (patch) | |
tree | f1433083ca238930bf3b8167d6c38a7a3cacb2ec /src/de/blinkt/openvpn/CIDRIP.java | |
parent | f743921f5812cd7f6c6b681382d60508ed02a4a9 (diff) |
Allow only one log window at a time (closes issue #26)
Make OpenvpnService honour net30 routes (closes issue #24)
Diffstat (limited to 'src/de/blinkt/openvpn/CIDRIP.java')
-rw-r--r-- | src/de/blinkt/openvpn/CIDRIP.java | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/de/blinkt/openvpn/CIDRIP.java b/src/de/blinkt/openvpn/CIDRIP.java index c2f0d821..ccb3836a 100644 --- a/src/de/blinkt/openvpn/CIDRIP.java +++ b/src/de/blinkt/openvpn/CIDRIP.java @@ -5,13 +5,7 @@ class CIDRIP{ int len; public CIDRIP(String ip, String mask){ mIp=ip; - String[] ipt = mask.split("\\."); - long netmask=0; - - netmask += Long.parseLong(ipt[0])<< 24; - netmask += Integer.parseInt(ipt[1])<< 16; - netmask += Integer.parseInt(ipt[2])<< 8; - netmask += Integer.parseInt(ipt[3]); + long netmask=getInt(mask); // Add 33. bit to ensure the loop terminates netmask += 1l << 32; @@ -36,14 +30,7 @@ class CIDRIP{ } public boolean normalise(){ - long ip=0; - - String[] ipt = mIp.split("\\."); - - ip += Long.parseLong(ipt[0])<< 24; - ip += Integer.parseInt(ipt[1])<< 16; - ip += Integer.parseInt(ipt[2])<< 8; - ip += Integer.parseInt(ipt[3]); + long ip=getInt(mIp); long newip = ip & (0xffffffffl << (32 -len)); if (newip != ip){ @@ -53,4 +40,19 @@ class CIDRIP{ return false; } } + static long getInt(String ipaddr) { + String[] ipt = ipaddr.split("\\."); + long ip=0; + + ip += Long.parseLong(ipt[0])<< 24; + ip += Integer.parseInt(ipt[1])<< 16; + ip += Integer.parseInt(ipt[2])<< 8; + ip += Integer.parseInt(ipt[3]); + + return ip; + } + public long getInt() { + return getInt(mIp); + } + }
\ No newline at end of file |