Fixes to in ports masked
Conflicts:
test_data/of13/oxm_bsn_in_ports_masked_128.data
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortMap.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortMap.java
index b666782..0454d39 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortMap.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortMap.java
@@ -1,64 +1,14 @@
package org.projectfloodlight.openflow.types;
-import org.jboss.netty.buffer.ChannelBuffer;
-public class OFPortMap implements OFValueType<OFPortMap> {
+public class OFPortMap extends Masked<OFPortBitmap> {
- static final int LENGTH = 16;
-
- private final long raw1;
- private final long raw2;
-
- public static final OFPortMap NONE = of(0, 0);
-
- private OFPortMap(long raw1, long raw2) {
- this.raw1 = raw1;
- this.raw2 = raw2;
-
- }
-
- public static OFPortMap of(long raw1, long raw2) {
- if (raw1 == 0 && raw2 == 0)
- return NONE;
- return new OFPortMap(raw1, raw2);
- }
-
- @Override
- public int getLength() {
- return LENGTH;
- }
-
- @Override
- public OFPortMap applyMask(OFPortMap mask) {
- return of(this.raw1 & mask.raw1, this.raw2 & mask.raw2);
- }
-
- public void write16Bytes(ChannelBuffer cb) {
- cb.writeLong(raw1);
- cb.writeLong(raw2);
- }
-
- public static OFPortMap read16Bytes(ChannelBuffer cb) {
- long raw1 = cb.readLong();
- long raw2 = cb.readLong();
- return of(raw1, raw2);
- }
-
- private static boolean isBitOn(long raw1, long raw2, int bit) {
- if (bit < 0 || bit >= 128)
- throw new IndexOutOfBoundsException("Port number is out of bounds");
- long word;
- if (bit < 64) {
- word = raw1;
- } else {
- word = raw2;
- bit -= 64;
- }
- return (word & ((long)1 << bit)) != 0;
+ private OFPortMap(OFPortBitmap mask) {
+ super(OFPortBitmap.NONE, mask);
}
public boolean isOn(OFPort port) {
- return isBitOn(raw1, raw2, port.getPortNumber());
+ return this.mask.isOn(port);
}
public static OFPortMap ofPorts(OFPort... ports) {
@@ -70,8 +20,16 @@
}
@Override
- public String toString() {
- return (String.format("%64s", Long.toBinaryString(raw2)) + String.format("%64s", Long.toBinaryString(raw1))).replaceAll(" ", "0");
+ public boolean equals(Object obj) {
+ if (!(obj instanceof OFPortMap))
+ return false;
+ OFPortMap other = (OFPortMap)obj;
+ return (other.value.equals(this.value) && other.mask.equals(this.mask));
+ }
+
+ @Override
+ public int hashCode() {
+ return 619 * mask.hashCode() + 257 * value.hashCode();
}
public static class Builder {
@@ -82,7 +40,7 @@
}
public boolean isOn(OFPort port) {
- return isBitOn(raw1, raw2, port.getPortNumber());
+ return OFPortBitmap.isBitOn(raw1, raw2, port.getPortNumber());
}
public Builder set(OFPort port) {
@@ -90,9 +48,9 @@
if (bit < 0 || bit >= 128)
throw new IndexOutOfBoundsException("Port number is out of bounds");
if (bit < 64) {
- raw1 |= ((long)1 << bit);
+ raw2 |= ((long)1 << bit);
} else {
- raw2 |= ((long)1 << (bit - 64));
+ raw1 |= ((long)1 << (bit - 64));
}
return this;
}
@@ -102,15 +60,15 @@
if (bit < 0 || bit >= 128)
throw new IndexOutOfBoundsException("Port number is out of bounds");
if (bit < 64) {
- raw1 &= ~((long)1 << bit);
+ raw2 &= ~((long)1 << bit);
} else {
- raw2 &= ~((long)1 << (bit - 64));
+ raw1 &= ~((long)1 << (bit - 64));
}
return this;
}
public OFPortMap build() {
- return OFPortMap.of(raw1, raw2);
+ return new OFPortMap(OFPortBitmap.of(raw1, raw2));
}
}