commit | b21043d1658f1f4255223ca8da1c05306fd4b4fb | [log] [tgz] |
---|---|---|
author | Aditya Vaja <aditya.vaja@bigswitch.com> | Tue Mar 11 13:34:06 2014 -0700 |
committer | Aditya Vaja <aditya.vaja@bigswitch.com> | Tue Mar 11 13:34:06 2014 -0700 |
tree | 61d853c178b560011bbc27b170e7fb2d4ebb07f6 | |
parent | 56b8b18888596e480186455f38d6d099d4e329c5 [diff] |
check for invalid masks in getSubnetBroadcastAddress in IPAWithMask
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java index ada2d38..f9eefc1 100644 --- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java +++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
@@ -10,6 +10,10 @@ public abstract IPVersion getIpVersion(); public IPAddress<?> getSubnetBroadcastAddress() { + if (!mask.isCidrMask()) { + throw new IllegalArgumentException("Mask Invalid " + mask + + " cannot get subnet for non CIDR mask"); + } return value.or(mask.not()); }
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java index bd2c945..a57b42a 100644 --- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java +++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
@@ -359,5 +359,13 @@ } catch (NullPointerException e) { assertNotNull(e.getMessage()); } + try { + IPv4AddressWithMask.of(IPv4Address.of("10.10.10.0"), + IPv4Address.of("255.0.255.0")) + .getSubnetBroadcastAddress(); + fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException e) { + assertNotNull(e.getMessage()); + } } }
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java index da31470..6963c21 100644 --- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java +++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
@@ -305,5 +305,13 @@ } catch (NullPointerException e) { assertNotNull(e.getMessage()); } + try { + IPv6AddressWithMask.of(IPv6Address.of("10:10::0"), + IPv6Address.of("ffff:0:ffff::")) + .getSubnetBroadcastAddress(); + fail("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException e) { + assertNotNull(e.getMessage()); + } } }