java_gen/prewritten: add 'ZERO/NONE' values to OFValueTypes
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
index 5e710ca..5ab940d 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ArpOpcode.java
@@ -60,7 +60,10 @@
private static final int MIN_OPCODE = 0;
private static final int MAX_OPCODE = 0xFFFF;
-
+
+ private static final int NONE_VAL = 0;
+ public static final ArpOpcode NONE = new ArpOpcode(NONE_VAL);
+
public static final ArpOpcode NO_MASK = new ArpOpcode(0xFFFFFFFF);
public static final ArpOpcode FULL_MASK = new ArpOpcode(0x00000000);
@@ -83,6 +86,8 @@
if (opcode < MIN_OPCODE || opcode > MAX_OPCODE)
throw new IllegalArgumentException("Invalid ARP opcode: " + opcode);
switch (opcode) {
+ case NONE_VAL:
+ return NONE;
case ARP_OPCODE_VAL_REQUEST:
return ARP_OPCODE_REQUEST;
case ARP_OPCODE_VAL_REPLY:
@@ -137,11 +142,11 @@
return new ArpOpcode(opcode);
}
}
-
+
public void write2Bytes(ChannelBuffer c) {
c.writeShort(this.opcode);
}
-
+
public static ArpOpcode read2Bytes(ChannelBuffer c) {
return ArpOpcode.of(c.readUnsignedShort());
}
@@ -150,9 +155,9 @@
public ArpOpcode applyMask(ArpOpcode mask) {
return ArpOpcode.of(this.opcode & mask.opcode);
}
-
+
public int getOpCode() {
return opcode;
}
-
+
}
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
index 4c18e21..abd4bff 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/EthType.java
@@ -5,7 +5,7 @@
/**
* EtherType field representation.
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*/
public class EthType implements OFValueType<EthType> {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
index 46ada58..a6544c9 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Code.java
@@ -3,7 +3,7 @@
import org.jboss.netty.buffer.ChannelBuffer;
/**
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*
*/
@@ -13,7 +13,10 @@
final static short MAX_CODE = 0xFF;
private final short code;
-
+
+ private static final short NONE_VAL = 0;
+ public static final ICMPv4Code NONE = new ICMPv4Code(NONE_VAL);
+
public static final ICMPv4Code NO_MASK = new ICMPv4Code((short)0xFFFF);
public static final ICMPv4Code FULL_MASK = new ICMPv4Code((short)0x0000);
@@ -22,6 +25,9 @@
}
public static ICMPv4Code of(short code) {
+ if(code == NONE_VAL)
+ return NONE;
+
if (code > MAX_CODE || code < 0)
throw new IllegalArgumentException("Illegal ICMPv4 code: " + code);
return new ICMPv4Code(code);
@@ -31,15 +37,15 @@
public int getLength() {
return LENGTH;
}
-
+
public short getCode() {
return code;
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.code);
}
-
+
public static ICMPv4Code readByte(ChannelBuffer c) {
return ICMPv4Code.of(c.readUnsignedByte());
}
@@ -49,5 +55,5 @@
return ICMPv4Code.of((short)(this.code & mask.code));
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
index 00a789b..5190d4e 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/ICMPv4Type.java
@@ -64,13 +64,16 @@
public static final ICMPv4Type ICMPV4_TYPE_PHOTURIS = new ICMPv4Type(ICMPV4_TYPE_VAL_PHOTURIS);
public static final ICMPv4Type ICMPV4_TYPE_EXPERIMENTAL_MOBILITY = new ICMPv4Type(ICMPV4_TYPE_VAL_EXPERIMENTAL_MOBILITY);
+ // HACK alert - we're disapproriating ICMPV4_TYPE_ECHO_REPLY (value 0) as 'none' as well
+ public static final ICMPv4Type NONE = ICMPV4_TYPE_ECHO_REPLY;
+
public static final ICMPv4Type NO_MASK = new ICMPv4Type((short)0xFFFF);
public static final ICMPv4Type FULL_MASK = new ICMPv4Type((short)0x0000);
private final short type;
-
+
private static final int MIN_TYPE = 0;
- private static final int MAX_TYPE = 0xFF;
+ private static final int MAX_TYPE = 0xFF;
private ICMPv4Type(short type) {
this.type = type;
@@ -145,15 +148,15 @@
public int getLength() {
return LENGTH;
}
-
+
public short getType() {
return type;
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.type);
}
-
+
public static ICMPv4Type readByte(ChannelBuffer c) {
return ICMPv4Type.of(c.readUnsignedByte());
}
@@ -163,5 +166,5 @@
return ICMPv4Type.of((short)(this.type & mask.type));
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index ad454eb..5ef301b 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -13,6 +13,9 @@
static final int LENGTH = 4;
private final int rawValue;
+ private final static int NONE_VAL = 0x0;
+ public final static IPv4Address NONE = new IPv4Address(NONE_VAL);
+
public static final IPv4Address NO_MASK = IPv4Address.of(0xFFFFFFFF);
public static final IPv4Address FULL_MASK = IPv4Address.of(0x00000000);
@@ -33,6 +36,8 @@
}
public static IPv4Address of(final int raw) {
+ if(raw == NONE_VAL)
+ return NONE;
return new IPv4Address(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
index a6ec439..45f10d1 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
@@ -1,6 +1,7 @@
package org.projectfloodlight.openflow.types;
public class IPv4AddressWithMask extends Masked<IPv4Address> {
+ public final static IPv4AddressWithMask NONE = of(IPv4Address.NONE, IPv4Address.NONE);
private IPv4AddressWithMask(int rawValue, int rawMask) {
super(IPv4Address.of(rawValue), IPv4Address.of(rawMask));
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 001f185..ea71c65 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -16,6 +16,10 @@
private final long raw1;
private final long raw2;
+ private final static long NONE_VAL1 = 0x0L;
+ private final static long NONE_VAL2 = 0x0L;
+ public static final IPv6Address NONE = new IPv6Address(NONE_VAL1, NONE_VAL2);
+
public static final IPv6Address NO_MASK = IPv6Address.of(0xFFFFFFFFFFFFFFFFl, 0xFFFFFFFFFFFFFFFFl);
public static final IPv6Address FULL_MASK = IPv6Address.of(0x0, 0x0);
@@ -123,6 +127,8 @@
}
public static IPv6Address of(final long raw1, final long raw2) {
+ if(raw1==NONE_VAL1 && raw2 == NONE_VAL2)
+ return NONE;
return new IPv6Address(raw1, raw2);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index 16ff5b1..dcaa0b6 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -4,33 +4,34 @@
import java.util.Arrays;
public class IPv6AddressWithMask extends Masked<IPv6Address> {
+ public final static IPv6AddressWithMask NONE = of(IPv6Address.NONE, IPv6Address.NONE);
private IPv6AddressWithMask(IPv6Address value, IPv6Address mask) {
super(value, mask);
}
-
+
public static IPv6AddressWithMask of(IPv6Address value, IPv6Address mask) {
return new IPv6AddressWithMask(value, mask);
}
-
+
@Override
public String toString() {
StringBuilder res = new StringBuilder();
- res.append(((IPv6Address)value).toString());
+ res.append(value.toString());
res.append('/');
-
- BigInteger maskint = new BigInteger(((IPv6Address)mask).getBytes());
+
+ BigInteger maskint = new BigInteger(mask.getBytes());
if (maskint.not().add(BigInteger.ONE).bitCount() == 1) {
// CIDR notation
res.append(maskint.bitCount());
} else {
// Full address mask
- res.append(((IPv6Address)mask).toString());
+ res.append(mask.toString());
}
-
+
return res.toString();
}
-
+
public static IPv6AddressWithMask of(final String string) {
int slashPos;
String ip = string;
@@ -58,10 +59,10 @@
throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
}
}
-
+
// Read IP
IPv6Address ipv6 = IPv6Address.of(ip);
-
+
if (maskAddress != null) {
// Full address mask
return IPv6AddressWithMask.of(ipv6, maskAddress);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
index 7feb0d9..7dbf9bb 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6FlowLabel.java
@@ -9,6 +9,9 @@
private final int label;
+ private final static int NONE_VAL = 0x0;
+ public static final IPv6FlowLabel NONE = new IPv6FlowLabel(NONE_VAL);
+
public static final IPv6FlowLabel NO_MASK = IPv6FlowLabel.of(0xFFFFFFFF);
public static final IPv6FlowLabel FULL_MASK = IPv6FlowLabel.of(0x0);
@@ -17,6 +20,8 @@
}
public static IPv6FlowLabel of(int label) {
+ if(label == NONE_VAL)
+ return NONE;
return new IPv6FlowLabel(label);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
index f311d9d..ec78315 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpDscp.java
@@ -72,6 +72,8 @@
static final int LENGTH = 1;
+ public static final IpDscp NONE = DSCP_0;
+
public static final IpDscp NO_MASK = DSCP_NO_MASK;
public static final IpDscp FULL_MASK = DSCP_0;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
index 5ecd251..7e1cdf0 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpEcn.java
@@ -10,6 +10,7 @@
ECN_11((byte)3),
ECN_NO_MASK((byte)0xFF);
+ public static final IpEcn NONE = ECN_00;
public static final IpEcn NO_MASK = ECN_NO_MASK;
public static final IpEcn FULL_MASK = ECN_00;
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
index e78c97b..36a76a2 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IpProtocol.java
@@ -4,7 +4,7 @@
/**
* IP-Protocol field representation
- *
+ *
* @author Yotam Harchol (yotam.harchol@bigswitch.com)
*/
public class IpProtocol implements OFValueType<IpProtocol> {
@@ -298,6 +298,8 @@
public static final IpProtocol IP_PROTO_HIP = new IpProtocol(IP_PROTO_NUM_HIP);
public static final IpProtocol IP_PROTO_SHIM6 = new IpProtocol(IP_PROTO_NUM_SHIM6);
+ public static final IpProtocol NONE = IP_PROTO_HOPOPT;
+
public static final IpProtocol NO_MASK = IP_PROTO_HOPOPT;
public static final IpProtocol FULL_MASK = new IpProtocol((short)0x0000);
@@ -627,7 +629,7 @@
public String toString() {
return Integer.toHexString(proto);
}
-
+
public void writeByte(ChannelBuffer c) {
c.writeByte(this.proto);
}
@@ -644,5 +646,5 @@
public short getIpProtocolNumber() {
return proto;
}
-
+
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
index 040d875..cc047ca 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/MacAddress.java
@@ -14,6 +14,9 @@
static final int MacAddrLen = 6;
private final long rawValue;
+ private final static long NONE_VAL = 0x0L;
+ public static final MacAddress NONE = new MacAddress(NONE_VAL);
+
public static final MacAddress NO_MASK = MacAddress.of(0xFFFFFFFFFFFFFFFFl);
public static final MacAddress FULL_MASK = MacAddress.of(0x0);
@@ -30,6 +33,9 @@
}
public static MacAddress of(final long raw) {
+ if(raw == NONE_VAL)
+ return NONE;
+
return new MacAddress(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
index 1d0aea7..e4eed77 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/Metadata.java
@@ -5,6 +5,10 @@
@Immutable
public class Metadata {
static final int LENGTH = 4;
+
+ private final static int NONE_VAL = 0;
+ public final static Metadata NONE = new Metadata(NONE_VAL);
+
private final int rawValue;
private Metadata(final int rawValue) {
@@ -12,6 +16,9 @@
}
public static Metadata of(final int raw) {
+ if(raw == NONE_VAL)
+ return NONE;
+
return new Metadata(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
index 861d4a8..766ade1 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFMetadata.java
@@ -8,6 +8,8 @@
private final U64 u64;
+ public static final OFMetadata NONE = OFMetadata.of(U64.ZERO);
+
public static final OFMetadata NO_MASK = OFMetadata.of(U64.ofRaw(0xFFFFFFFFFFFFFFFFl));
public static final OFMetadata FULL_MASK = OFMetadata.of(U64.ofRaw(0x0));
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java
deleted file mode 100644
index ca662f7..0000000
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPhysicalPort.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.projectfloodlight.openflow.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.projectfloodlight.openflow.exceptions.OFParseError;
-import org.projectfloodlight.openflow.protocol.OFMessageReader;
-import org.projectfloodlight.openflow.protocol.Writeable;
-
-/**
- * A wrapper around the OpenFlow physical port description. The interfaces to
- * this object are version agnostic.
- *
- * @author capveg
- */
-
-public class OFPhysicalPort implements OFValueType<OFPhysicalPort>, Writeable {
-
- static final int LENGTH = 4;
-
- private final int port;
-
- public static final OFPhysicalPort NO_MASK = OFPhysicalPort.of(0xFFFFFFFF);
- public static final OFPhysicalPort FULL_MASK = OFPhysicalPort.of(0x0);
-
- private OFPhysicalPort(int port) {
- this.port = port;
- }
-
- public static OFPhysicalPort of(int port) {
- return new OFPhysicalPort(port);
- }
-
- @Override
- public int getLength() {
- return LENGTH;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof OFPhysicalPort))
- return false;
- OFPhysicalPort other = (OFPhysicalPort)obj;
- if (other.port != this.port)
- return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 59;
- int result = 1;
- result = prime * result + port;
- return result;
- }
-
- @Override
- public String toString() {
- return Integer.toHexString(port);
- }
-
- public void write4Bytes(ChannelBuffer c) {
- c.writeInt(this.port);
- }
-
- @Override
- public void writeTo(ChannelBuffer bb) {
- write4Bytes(bb);
- }
-
- public static OFPhysicalPort read4Bytes(ChannelBuffer c) throws OFParseError {
- return OFPhysicalPort.of((int)(c.readUnsignedInt() & 0xFFFFFFFF));
- }
-
- @Override
- public OFPhysicalPort applyMask(OFPhysicalPort mask) {
- return OFPhysicalPort.of(this.port & mask.port);
- }
-
- public int getPortNumber() {
- return port;
- }
-
- public final static Reader READER = new Reader();
- private static class Reader implements OFMessageReader<OFPhysicalPort> {
- @Override
- public OFPhysicalPort readFrom(ChannelBuffer bb) throws OFParseError {
- return OFPhysicalPort.read4Bytes(bb);
- }
-
- }
-}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
index d65d0aa..db7bd5f 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPort.java
@@ -17,9 +17,10 @@
@Immutable
public class OFPort implements OFValueType<OFPort> {
static final int LENGTH = 4;
-
+
// private int constants (OF1.1+) to avoid duplication in the code
// should not have to use these outside this class
+ private static final int OFPP_NONE_INT = 0x0;
private static final int OFPP_ANY_INT = 0xFFffFFff;
private static final int OFPP_LOCAL_INT = 0xFFffFFfe;
private static final int OFPP_CONTROLLER_INT = 0xFFffFFfd;
@@ -86,9 +87,12 @@
*/
public final static OFPort ANY = new NamedPort(OFPP_ANY_INT, "any");
+ /** port number 0, read of the wire, e.g, if not set */
+ public final static OFPort NONE = new NamedPort(OFPP_NONE_INT, "none");
+
public static final OFPort NO_MASK = OFPort.of(0xFFFFFFFF);
public static final OFPort FULL_MASK = OFPort.of(0x0);
-
+
/** cache of frequently used ports */
private static class PrecachedPort {
private final static OFPort p1 = new OFPort(1);
@@ -158,6 +162,8 @@
*/
public static OFPort ofInt(final int portNumber) {
switch (portNumber) {
+ case 0:
+ return NONE;
case 1:
return PrecachedPort.p1;
case 2:
@@ -300,6 +306,8 @@
*/
public static OFPort ofShort(final short portNumber) {
switch (portNumber) {
+ case 0:
+ return NONE;
case 1:
return PrecachedPort.p1;
case 2:
@@ -499,7 +507,7 @@
public int getLength() {
return LENGTH;
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OFPort))
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
index 4cf5b90..6efd813 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/TransportPort.java
@@ -14,6 +14,9 @@
static final int MAX_PORT = 0xFFFF;
static final int MIN_PORT = 0;
+ private final static int NONE_VAL = 0;
+ public final static TransportPort NONE = new TransportPort(NONE_VAL);
+
public static final TransportPort NO_MASK = new TransportPort(0xFFFFFFFF);
public static final TransportPort FULL_MASK = TransportPort.of(0x0);
@@ -24,7 +27,9 @@
}
public static TransportPort of(int port) {
- if (port < MIN_PORT || port > MAX_PORT) {
+ if(port == NONE_VAL)
+ return NONE;
+ else if (port < MIN_PORT || port > MAX_PORT) {
throw new IllegalArgumentException("Illegal transport layer port number: " + port);
}
return new TransportPort(port);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
index 55a467e..43bec7a 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U16.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U16 implements Writeable, OFValueType<U16> {
+ private final static short ZERO_VAL = 0;
+ public final static U16 ZERO = new U16(ZERO_VAL);
+
public static int f(final short i) {
return i & 0xffff;
}
@@ -38,11 +41,13 @@
}
public static final U16 of(int value) {
- return new U16(t(value));
+ return ofRaw(t(value));
}
- public static final U16 ofRaw(short value) {
- return new U16(value);
+ public static final U16 ofRaw(short raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
+ return new U16(raw);
}
public int getValue() {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
index 2634ed1..f56a528 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U32.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U32 implements Writeable, OFValueType<U32> {
+ private final static int ZERO_VAL = 0;
+ public final static U32 ZERO = new U32(ZERO_VAL);
+
private final int raw;
private U32(int raw) {
@@ -30,11 +33,13 @@
}
public static U32 of(long value) {
- return new U32(U32.t(value));
+ return ofRaw(U32.t(value));
}
- public static U32 ofRaw(int value) {
- return new U32(value);
+ public static U32 ofRaw(int raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
+ return new U32(raw);
}
public long getValue() {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
index 5de62dc..3b89e24 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
@@ -24,6 +24,8 @@
public class U64 implements Writeable, OFValueType<U64> {
private static final long UNSIGNED_MASK = 0x7fffffffffffffffL;
+ private final static long ZERO_VAL = 0;
+ public final static U64 ZERO = new U64(ZERO_VAL);
private final long raw;
@@ -36,6 +38,8 @@
}
public static U64 ofRaw(final long raw) {
+ if(raw == ZERO_VAL)
+ return ZERO;
return new U64(raw);
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
index 41e740e..f85bfae 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U8.java
@@ -23,6 +23,9 @@
import org.projectfloodlight.openflow.protocol.Writeable;
public class U8 implements Writeable, OFValueType<U8> {
+ private final static byte ZERO_VAL = 0;
+ public final static U8 ZERO = new U8(ZERO_VAL);
+
private final byte raw;
private U8(byte raw) {
@@ -30,6 +33,9 @@
}
public static final U8 of(short value) {
+ if(value == ZERO_VAL)
+ return ZERO;
+
return new U8(t(value));
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
index f6993fe..7d15fb7 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanPcp.java
@@ -6,10 +6,12 @@
public class VlanPcp implements OFValueType<VlanPcp> {
private static final byte VALIDATION_MASK = 0x07;
+ private static final byte NONE_VAL = 0x00;
static final int LENGTH = 1;
private final byte pcp;
+ public static final VlanPcp NONE = new VlanPcp(NONE_VAL);
public static final VlanPcp NO_MASK = new VlanPcp((byte)0xFF);
public static final VlanPcp FULL_MASK = VlanPcp.of((byte)0x0);
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
index 63b8831..5c23779 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/VlanVid.java
@@ -6,8 +6,10 @@
public class VlanVid implements OFValueType<VlanVid> {
private static final short VALIDATION_MASK = 0x0FFF;
+ private static final short NONE_VAL = 0x0000;
final static int LENGTH = 2;
+ public static final VlanVid NONE = new VlanVid(NONE_VAL);
public static final VlanVid NO_MASK = new VlanVid((short)0xFFFF);
public static final VlanVid FULL_MASK = VlanVid.of((short)0x0);
@@ -18,7 +20,9 @@
}
public static VlanVid of(short vid) {
- if ((vid & VALIDATION_MASK) != vid)
+ if(vid == NONE_VAL)
+ return NONE;
+ else if ((vid & VALIDATION_MASK) != vid)
throw new IllegalArgumentException("Illegal VLAN VID value: " + vid);
return new VlanVid(vid);
}