commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r761980 - in /commons/proper/net/branches/NET_2_0/src/main/java: examples/SubnetUtilsExample.java org/apache/commons/net/util/SubnetUtils.java
Date Sat, 04 Apr 2009 18:29:29 GMT
Author: rwinston
Date: Sat Apr  4 18:29:29 2009
New Revision: 761980

URL: http://svn.apache.org/viewvc?rev=761980&view=rev
Log:
NET-262: Throw an exception if netmask bits are not in (0,x]

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java?rev=761980&r1=761979&r2=761980&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java Sat
Apr  4 18:29:29 2009
@@ -30,7 +30,7 @@
 public class SubnetUtilsExample {
     
     public static void main(String[] args) {
-        String subnet = "192.168.0.1/29";
+        String subnet = "192.168.0.3/31";
         SubnetUtils utils = new SubnetUtils(subnet);
         SubnetInfo info = utils.getInfo();
         
@@ -48,9 +48,9 @@
                 Integer.toBinaryString(info.asInteger(info.getNetworkAddress())));
         System.out.printf("Broadcast Address:\t\t%s\t[%s]\n", info.getBroadcastAddress(),

                 Integer.toBinaryString(info.asInteger(info.getBroadcastAddress())));
-        System.out.printf("First Usable Address:\t\t%s\t[%s]\n", info.getLowAddress(), 
+        System.out.printf("Low Address:\t\t\t%s\t[%s]\n", info.getLowAddress(), 
                 Integer.toBinaryString(info.asInteger(info.getLowAddress())));
-        System.out.printf("Last Usable Address:\t\t%s\t[%s]\n", info.getHighAddress(), 
+        System.out.printf("High Address:\t\t\t%s\t[%s]\n", info.getHighAddress(), 
                 Integer.toBinaryString(info.asInteger(info.getHighAddress())));
         
         System.out.printf("Total usable addresses: \t%d\n", info.getAddressCount());

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java?rev=761980&r1=761979&r2=761980&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
Sat Apr  4 18:29:29 2009
@@ -199,7 +199,7 @@
      * Convenience function to check integer boundaries
      */
     private int rangeCheck(int value, int begin, int end) {
-        if (value >= begin && value <= end)
+        if (value > begin && value <= end) // (0,nbits]
             return value;
 
         throw new IllegalArgumentException("Value out of range: [" + value + "]");



Mime
View raw message