Added an extra validation check so that 09/2409/3
authorAsad Ahmed <asaahmed@cisco.com>
Tue, 5 Nov 2013 19:37:40 +0000 (11:37 -0800)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 6 Nov 2013 00:36:34 +0000 (00:36 +0000)
the gateway mask cannot be 0 or 32

Change-Id: I78a4174c7800fcca7bdd95d03a520db5db01983d
Signed-off-by: Asad Ahmed <asaahmed@cisco.com>
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java

index b0d5861..577c039 100644 (file)
@@ -104,6 +104,9 @@ public class SubnetConfig implements Cloneable, Serializable {
         if (!NetUtils.isIPAddressValid(subnet)) {
             return new Status(StatusCode.BADREQUEST, String.format("Invalid Subnet configuration: Invalid address: %s", subnet));
         }
+        if((this.getIPMaskLen() == 0) || (this.getIPMaskLen() == 32)) {
+            return new Status(StatusCode.BADREQUEST, String.format("Invalid Subnet configuration: Invalid mask: /%s", this.getIPMaskLen()));
+        }
         byte[] bytePrefix = NetUtils.getSubnetPrefix(this.getIPAddress(), this.getIPMaskLen()).getAddress();
         long prefix = BitBufferHelper.getLong(bytePrefix);
         if (prefix == 0) {