# HG changeset patch # User kono # Date 1404303680 -32400 # Node ID a8ae952191b859a1913c831f17265e74d79b3fef # Parent a106bbed188894fcb5494f7a3a5194e2dc49579d netmask done diff -r a106bbed1888 -r a8ae952191b8 src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java --- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Wed Jul 02 20:35:28 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java Wed Jul 02 21:21:20 2014 +0900 @@ -49,9 +49,9 @@ byte[] netmask = ipaddress.getAddress().getAddress(); for(int i = 0; i < netmask.length; i++) { int bitpos = i * 8; - if (bitpos+8 > prefix) { - netmask[i] = 0; - } else if (bitpos > prefix) { + if (bitpos+7 < prefix) { + netmask[i] = (byte)0xff; + } else if (bitpos < prefix) { // ex. bitpos = 0, prefix = 2 // bitpos+8-prefix // 1100 0000 @@ -61,6 +61,8 @@ bytemask |= 0x80; } netmask[i] = (byte)bytemask; + } else { + netmask[i] = 0; } } return netmask ;