Mercurial > hg > Members > riono > TreeVNC_ja_comment
changeset 213:a8ae952191b8
netmask done
author | kono |
---|---|
date | Wed, 02 Jul 2014 21:21:20 +0900 |
parents | a106bbed1888 |
children | e13912948369 |
files | src/main/java/jp/ac/u_ryukyu/treevnc/TreeVNCNetwork.java |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 ;