Yuta HIGUCHI

IpPrefix fix

- addied  method #prefixLength()
- ANY: array is mutable, should not be exposed public

Change-Id: I4197dbd79370fa39c92468b9c31f0ae04bc01fcd
......@@ -36,7 +36,6 @@ import org.onlab.onos.openflow.controller.PacketListener;
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 @@ public class OpenFlowPacketProviderTest {
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 @@ public class OpenFlowPacketProviderTest {
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)
......
......@@ -24,7 +24,7 @@ public final class IpPrefix {
/**
* 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 @@ public final class IpPrefix {
*
* @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
......