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; ...@@ -36,7 +36,6 @@ import org.onlab.onos.openflow.controller.PacketListener;
36 import org.onlab.onos.openflow.controller.RoleState; 36 import org.onlab.onos.openflow.controller.RoleState;
37 import org.onlab.packet.ARP; 37 import org.onlab.packet.ARP;
38 import org.onlab.packet.Ethernet; 38 import org.onlab.packet.Ethernet;
39 -import org.onlab.packet.IpPrefix;
40 import org.projectfloodlight.openflow.protocol.OFFactory; 39 import org.projectfloodlight.openflow.protocol.OFFactory;
41 import org.projectfloodlight.openflow.protocol.OFMessage; 40 import org.projectfloodlight.openflow.protocol.OFMessage;
42 import org.projectfloodlight.openflow.protocol.OFPacketIn; 41 import org.projectfloodlight.openflow.protocol.OFPacketIn;
...@@ -76,6 +75,8 @@ public class OpenFlowPacketProviderTest { ...@@ -76,6 +75,8 @@ public class OpenFlowPacketProviderTest {
76 private static final TrafficTreatment TR = treatment(INST1, INST2); 75 private static final TrafficTreatment TR = treatment(INST1, INST2);
77 private static final TrafficTreatment TR_MISSING = treatment(INST1, INST3); 76 private static final TrafficTreatment TR_MISSING = treatment(INST1, INST3);
78 77
78 + private static final byte[] ANY = new byte [] {0, 0, 0, 0};
79 +
79 private final OpenFlowPacketProvider provider = new OpenFlowPacketProvider(); 80 private final OpenFlowPacketProvider provider = new OpenFlowPacketProvider();
80 private final TestPacketRegistry registry = new TestPacketRegistry(); 81 private final TestPacketRegistry registry = new TestPacketRegistry();
81 private final TestController controller = new TestController(); 82 private final TestController controller = new TestController();
...@@ -113,10 +114,10 @@ public class OpenFlowPacketProviderTest { ...@@ -113,10 +114,10 @@ public class OpenFlowPacketProviderTest {
113 MacAddress mac2 = MacAddress.of("00:00:00:22:00:02"); 114 MacAddress mac2 = MacAddress.of("00:00:00:22:00:02");
114 115
115 ARP arp = new ARP(); 116 ARP arp = new ARP();
116 - arp.setSenderProtocolAddress(IpPrefix.ANY) 117 + arp.setSenderProtocolAddress(ANY)
117 .setSenderHardwareAddress(mac1.getBytes()) 118 .setSenderHardwareAddress(mac1.getBytes())
118 .setTargetHardwareAddress(mac2.getBytes()) 119 .setTargetHardwareAddress(mac2.getBytes())
119 - .setTargetProtocolAddress(IpPrefix.ANY) 120 + .setTargetProtocolAddress(ANY)
120 .setHardwareType((short) 0) 121 .setHardwareType((short) 0)
121 .setProtocolType((short) 0) 122 .setProtocolType((short) 0)
122 .setHardwareAddressLength((byte) 6) 123 .setHardwareAddressLength((byte) 6)
......
...@@ -24,7 +24,7 @@ public final class IpPrefix { ...@@ -24,7 +24,7 @@ public final class IpPrefix {
24 /** 24 /**
25 * Default value indicating an unspecified address. 25 * Default value indicating an unspecified address.
26 */ 26 */
27 - public static final byte [] ANY = new byte [] {0, 0, 0, 0}; 27 + static final byte[] ANY = new byte [] {0, 0, 0, 0};
28 28
29 protected Version version; 29 protected Version version;
30 30
...@@ -152,11 +152,20 @@ public final class IpPrefix { ...@@ -152,11 +152,20 @@ public final class IpPrefix {
152 * 152 *
153 * @return a byte array 153 * @return a byte array
154 */ 154 */
155 - public byte [] toOctets() { 155 + public byte[] toOctets() {
156 return Arrays.copyOf(this.octets, INET_LEN); 156 return Arrays.copyOf(this.octets, INET_LEN);
157 } 157 }
158 158
159 /** 159 /**
160 + * Returns the IP address prefix length.
161 + *
162 + * @return prefix length
163 + */
164 + public int prefixLength() {
165 + return netmask;
166 + }
167 +
168 + /**
160 * Returns the integral value of this IP address. 169 * Returns the integral value of this IP address.
161 * 170 *
162 * @return the IP address's value as an integer 171 * @return the IP address's value as an integer
......