summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/CIDRIP.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-18 14:11:37 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-18 14:11:37 +0200
commit94387a6e42cf76d8fcaa5f9aab0355164d0bbe2b (patch)
treef1433083ca238930bf3b8167d6c38a7a3cacb2ec /src/de/blinkt/openvpn/CIDRIP.java
parent7ad69e645000fc66951a79104b0ce5ac3478b9f3 (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.java32
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