IpPrefix fix
- addied method #prefixLength()
- ANY: array is mutable, should not be exposed public
Change-Id: I4197dbd79370fa39c92468b9c31f0ae04bc01fcd
diff --git a/providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java b/providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
index e117ba6..101856e 100644
--- a/providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
+++ b/providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
@@ -36,7 +36,6 @@
import org.onlab.onos.openflow.controller.RoleState;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpPrefix;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
@@ -76,6 +75,8 @@
private static final TrafficTreatment TR = treatment(INST1, INST2);
private static final TrafficTreatment TR_MISSING = treatment(INST1, INST3);
+ private static final byte[] ANY = new byte [] {0, 0, 0, 0};
+
private final OpenFlowPacketProvider provider = new OpenFlowPacketProvider();
private final TestPacketRegistry registry = new TestPacketRegistry();
private final TestController controller = new TestController();
@@ -113,10 +114,10 @@
MacAddress mac2 = MacAddress.of("00:00:00:22:00:02");
ARP arp = new ARP();
- arp.setSenderProtocolAddress(IpPrefix.ANY)
+ arp.setSenderProtocolAddress(ANY)
.setSenderHardwareAddress(mac1.getBytes())
.setTargetHardwareAddress(mac2.getBytes())
- .setTargetProtocolAddress(IpPrefix.ANY)
+ .setTargetProtocolAddress(ANY)
.setHardwareType((short) 0)
.setProtocolType((short) 0)
.setHardwareAddressLength((byte) 6)
diff --git a/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java b/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
index c73bf9a..4ae8be7 100644
--- a/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
+++ b/utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
@@ -24,7 +24,7 @@
/**
* Default value indicating an unspecified address.
*/
- public static final byte [] ANY = new byte [] {0, 0, 0, 0};
+ static final byte[] ANY = new byte [] {0, 0, 0, 0};
protected Version version;
@@ -152,11 +152,20 @@
*
* @return a byte array
*/
- public byte [] toOctets() {
+ public byte[] toOctets() {
return Arrays.copyOf(this.octets, INET_LEN);
}
/**
+ * Returns the IP address prefix length.
+ *
+ * @return prefix length
+ */
+ public int prefixLength() {
+ return netmask;
+ }
+
+ /**
* Returns the integral value of this IP address.
*
* @return the IP address's value as an integer