* Added JsonSerialize to the Flow-related containers.
* Implement the remaining toString() methods that were
returning empty strings.
diff --git a/src/main/java/net/floodlightcontroller/util/CallerId.java b/src/main/java/net/floodlightcontroller/util/CallerId.java
index 898da31..200b9e0 100644
--- a/src/main/java/net/floodlightcontroller/util/CallerId.java
+++ b/src/main/java/net/floodlightcontroller/util/CallerId.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.CallerIdSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing a Caller ID for an ONOS component.
*/
+@JsonSerialize(using=CallerIdSerializer.class)
public class CallerId {
private String value;
diff --git a/src/main/java/net/floodlightcontroller/util/DataPath.java b/src/main/java/net/floodlightcontroller/util/DataPath.java
index 2374fbe..34fc1f2 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPath.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPath.java
@@ -4,10 +4,15 @@
import net.floodlightcontroller.util.SwitchPort;
import net.floodlightcontroller.util.FlowEntry;
+import net.floodlightcontroller.util.serializers.DataPathSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing the Data Path.
*/
+@JsonSerialize(using=DataPathSerializer.class)
public class DataPath {
private SwitchPort srcPort; // The source port
private SwitchPort dstPort; // The destination port
@@ -70,12 +75,20 @@
/**
* Convert the data path to a string.
*
+ * The string has the following form:
+ * [src:01:01:01:01:01:01:01:01/1111 flowEntry:<entry1> flowEntry:<entry2> flowEntry:<entry3> dst:02:02:02:02:02:02:02:02/2222]
+ *
* @return the data path as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[src:" + this.srcPort.toString();
+
+ for (FlowEntry fe : flowEntries) {
+ ret += " flowEntry:" + fe.toString();
+ }
+ ret += " dst:" + this.dstPort.toString() + "]";
+
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
index 5c9e02c..9dd7dbb 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
@@ -1,10 +1,15 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.SwitchPort;
+import net.floodlightcontroller.util.serializers.DataPathEndpointsSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing the Data Path Endpoints.
*/
+@JsonSerialize(using=DataPathEndpointsSerializer.class)
public class DataPathEndpoints {
private SwitchPort srcPort; // The source port
private SwitchPort dstPort; // The destination port
@@ -61,12 +66,15 @@
/**
* Convert the data path endpoints to a string.
*
+ * The string has the following form:
+ * [src:01:01:01:01:01:01:01:01/1111 dst:02:02:02:02:02:02:02:02/2222]
+ *
* @return the data path endpoints as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[src:" + this.srcPort.toString() +
+ " dst:" + this.dstPort.toString() + "]";
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/Dpid.java b/src/main/java/net/floodlightcontroller/util/Dpid.java
index 3a8d1e8..7787953 100644
--- a/src/main/java/net/floodlightcontroller/util/Dpid.java
+++ b/src/main/java/net/floodlightcontroller/util/Dpid.java
@@ -1,8 +1,15 @@
package net.floodlightcontroller.util;
+import org.openflow.util.HexString;
+import net.floodlightcontroller.util.serializers.DpidSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing a network switch DPID.
*/
+@JsonSerialize(using=DpidSerializer.class)
public class Dpid {
static public long UNKNOWN = 0;
@@ -41,14 +48,12 @@
}
/**
- * Convert the DPID value to a ':' separated hex string.
+ * Convert the DPID value to a ':' separated hexadecimal string.
*
- * @return the DPID value as a ':' separated hex string.
+ * @return the DPID value as a ':' separated hexadecimal string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return HexString.toHexString(this.value);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntry.java b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
index e9c4bbe..d45d87f 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntry.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
@@ -5,6 +5,10 @@
import net.floodlightcontroller.util.FlowEntryId;
import net.floodlightcontroller.util.FlowEntryMatch;
import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.serializers.FlowEntrySerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The Flow Entry state as set by the user (via the ONOS API).
@@ -34,6 +38,7 @@
* NOTE: The specification is incomplete. E.g., the entry needs to
* support multiple in-ports and multiple out-ports.
*/
+@JsonSerialize(using=FlowEntrySerializer.class)
public class FlowEntry {
private FlowEntryId flowEntryId; // The Flow Entry ID
private FlowEntryMatch flowEntryMatch; // The Flow Entry Match
@@ -213,12 +218,25 @@
/**
* Convert the flow entry to a string.
*
+ * The string has the following form:
+ * [flowEntryId:XXX flowEntryMatch:XXX flowEntryActions:XXX dpid:XXX
+ * inPort:XXX outPort:XXX flowEntryUserState:XXX flowEntrySwitchState:XXX
+ * flowEntryErrorState:XXX]
* @return the flow entry as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[flowEntryId:" + this.flowEntryId.toString();
+ ret += " flowEntryMatch:" + this.flowEntryMatch.toString();
+ ret += " flowEntryActions:" + this.flowEntryActions.toString();
+ ret += " dpid:" + this.dpid.toString();
+ ret += " inPort:" + this.inPort.toString();
+ ret += " outPort:" + this.outPort.toString();
+ ret += " flowEntryUserState:" + this.flowEntryUserState;
+ ret += " flowEntrySwitchState:" + this.flowEntrySwitchState;
+ ret += " flowEntryErrorState:" + this.flowEntryErrorState.toString();
+ ret += "]";
+
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java b/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
index 90f42fb..b683d2c 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
@@ -1,5 +1,10 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowEntryActionsSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing the Flow Entry set of actions.
*
@@ -8,6 +13,7 @@
* NOTE: This is just an empty placeholder (for now). The implied action is
* forwarding on a single port.
*/
+@JsonSerialize(using=FlowEntryActionsSerializer.class)
public class FlowEntryActions {
/**
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java b/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
index 63c103d..0dfae09 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowEntryErrorStateSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing the Flow Entry error state.
*/
+@JsonSerialize(using=FlowEntryErrorStateSerializer.class)
public class FlowEntryErrorState {
private short type; // The error type (e.g., see OF-1.3.1 spec, pp. 95)
private short code; // The error code (e.g., see OF-1.3.1 spec, pp. 95)
@@ -54,12 +60,14 @@
/**
* Convert the error type and code to a string.
*
+ * The string has the following form:
+ * [type:1 code:2]
+ *
* @return the error type and code as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[type:" + this.type + " code:" + code + "]";
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryId.java b/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
index 4736ed5..bf1fc7d 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowEntryIdSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing a Flow Entry ID.
*/
+@JsonSerialize(using=FlowEntryIdSerializer.class)
public class FlowEntryId {
private long value;
@@ -39,14 +45,12 @@
}
/**
- * Convert the Flow Entry ID value to a string.
+ * Convert the Flow Entry ID value to a hexadecimal string.
*
- * @return the Flow Entry ID value to a string.
+ * @return the Flow Entry ID value to a hexadecimal string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return Long.toHexString(this.value);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
index a8f43f5..ddc65d0 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
@@ -2,6 +2,10 @@
import net.floodlightcontroller.util.MACAddress;
import net.floodlightcontroller.util.IPv4Net;
+import net.floodlightcontroller.util.serializers.FlowEntryMatchSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing the Flow Entry Matching filter.
@@ -15,6 +19,7 @@
* more matching fields, we need to indicate which fields need to be
* matched, etc.
*/
+@JsonSerialize(using=FlowEntryMatchSerializer.class)
public class FlowEntryMatch {
private MACAddress srcMac; // Matching source MAC address
private MACAddress dstMac; // Matching destination MAC address
@@ -94,12 +99,18 @@
/**
* Convert the matching filter to a string.
*
+ * The string has the following form:
+ * [srcMac:XXX dstMac:XXX srcIPv4Net:XXX dstIPv4Net:XXX]
+ *
* @return the matching filter as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[srcMac: " + this.srcMac.toString();
+ ret += " dstMac:" + this.dstMac.toString();
+ ret += " srcIPv4Net:" + this.srcIPv4Net.toString();
+ ret += " dstIPv4Net:" + this.dstIPv4Net.toString();
+ ret += "]";
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowId.java b/src/main/java/net/floodlightcontroller/util/FlowId.java
index 827c1d9..a8beaa0 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowId.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowId.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowIdSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing a Flow ID.
*/
+@JsonSerialize(using=FlowIdSerializer.class)
public class FlowId {
private long value;
@@ -39,14 +45,12 @@
}
/**
- * Convert the Flow ID value to a string.
+ * Convert the Flow ID value to a hexadecimal string.
*
- * @return the Flow ID value to a string.
+ * @return the Flow ID value to a hexadecimal string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return "0x" + Long.toHexString(this.value);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowPath.java b/src/main/java/net/floodlightcontroller/util/FlowPath.java
index 46a1f82..b67fabe 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowPath.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowPath.java
@@ -3,10 +3,15 @@
import net.floodlightcontroller.util.CallerId;
import net.floodlightcontroller.util.DataPath;
import net.floodlightcontroller.util.FlowId;
+import net.floodlightcontroller.util.serializers.FlowPathSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing the Flow Path.
*/
+@JsonSerialize(using=FlowPathSerializer.class)
public class FlowPath {
private FlowId flowId; // The Flow ID
private CallerId installerId; // The Caller ID of the path installer
@@ -73,8 +78,9 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
+ String ret = "[flowId:" + this.flowId.toString();
+ ret += " installerId:" + this.installerId.toString();
+ ret += " dataPath:" + this.dataPath.toString();
return ret;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/IPv4.java b/src/main/java/net/floodlightcontroller/util/IPv4.java
index b4fc787..3f4f350 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv4.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv4.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.IPv4Serializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing an IPv4 address.
*/
+@JsonSerialize(using=IPv4Serializer.class)
public class IPv4 {
private int value;
@@ -45,8 +51,9 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return ((this.value >> 24) & 0xFF) + "." +
+ ((this.value >> 16) & 0xFF) + "." +
+ ((this.value >> 8) & 0xFF) + "." +
+ (this.value & 0xFF);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/IPv4Net.java b/src/main/java/net/floodlightcontroller/util/IPv4Net.java
index 6c4c651..f64ccb8 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv4Net.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv4Net.java
@@ -1,10 +1,15 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.IPv4;
+import net.floodlightcontroller.util.serializers.IPv4NetSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv4 network address.
*/
+@JsonSerialize(using=IPv4NetSerializer.class)
public class IPv4Net {
private IPv4 address; // The IPv4 address
private short prefixLen; // The prefix length
@@ -59,8 +64,6 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return this.address.toString() + "/" + this.prefixLen;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/IPv6.java b/src/main/java/net/floodlightcontroller/util/IPv6.java
index dfa071b..d4461c0 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv6.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv6.java
@@ -1,8 +1,15 @@
package net.floodlightcontroller.util;
+import org.openflow.util.HexString;
+import net.floodlightcontroller.util.serializers.IPv6Serializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing an IPv6 address.
*/
+@JsonSerialize(using=IPv6Serializer.class)
public class IPv6 {
private long valueHigh; // The higher (more significant) 64 bits
private long valueLow; // The lower (less significant) 64 bits
@@ -60,8 +67,7 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return HexString.toHexString(this.valueHigh) + ":" +
+ HexString.toHexString(this.valueLow);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/IPv6Net.java b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
index 85de4f7..1942293 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv6Net.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
@@ -1,10 +1,15 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.IPv6;
+import net.floodlightcontroller.util.serializers.IPv6NetSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv6 network address.
*/
+@JsonSerialize(using=IPv6NetSerializer.class)
public class IPv6Net {
private IPv6 address; // The IPv6 address
private short prefixLen; // The prefix length
@@ -59,8 +64,6 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return this.address.toString() + "/" + this.prefixLen;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/Port.java b/src/main/java/net/floodlightcontroller/util/Port.java
index 8fbb727..0bfb07a 100644
--- a/src/main/java/net/floodlightcontroller/util/Port.java
+++ b/src/main/java/net/floodlightcontroller/util/Port.java
@@ -1,8 +1,14 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.PortSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
/**
* The class representing a network port of a switch.
*/
+@JsonSerialize(using=PortSerializer.class)
public class Port {
private short value;
@@ -45,8 +51,6 @@
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return Short.toString(this.value);
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/SwitchPort.java b/src/main/java/net/floodlightcontroller/util/SwitchPort.java
index 31061bc..462cdfb 100644
--- a/src/main/java/net/floodlightcontroller/util/SwitchPort.java
+++ b/src/main/java/net/floodlightcontroller/util/SwitchPort.java
@@ -2,10 +2,15 @@
import net.floodlightcontroller.util.Dpid;
import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.serializers.SwitchPortSerializer;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing a Switch-Port.
*/
+@JsonSerialize(using=SwitchPortSerializer.class)
public class SwitchPort {
private Dpid dpid; // The DPID of the switch
private Port port; // The port of the switch
@@ -55,12 +60,13 @@
/**
* Convert the Switch-Port value to a string.
*
+ * The string has the following form:
+ * 01:02:03:04:05:06:07:08/1234
+ *
* @return the Switch-Port value as a string.
*/
@Override
public String toString() {
- String ret = "";
- // TODO: Implement it!
- return ret;
+ return this.dpid.toString() + "/" + this.port;
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/CallerIdSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/CallerIdSerializer.java
new file mode 100644
index 0000000..9935324
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/CallerIdSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.CallerId;
+
+/**
+ * Serialize a Caller ID as a string.
+ */
+public class CallerIdSerializer extends JsonSerializer<CallerId> {
+
+ @Override
+ public void serialize(CallerId callerId, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(callerId.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/DataPathEndpointsSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/DataPathEndpointsSerializer.java
new file mode 100644
index 0000000..e05c21d
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/DataPathEndpointsSerializer.java
@@ -0,0 +1,26 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.DataPathEndpoints;
+
+/**
+ * Serialize a DataPathEndpoints as a string.
+ */
+public class DataPathEndpointsSerializer extends JsonSerializer<DataPathEndpoints> {
+
+ @Override
+ public void serialize(DataPathEndpoints dataPathEndpoints,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("srcPort", dataPathEndpoints.srcPort());
+ jGen.writeObjectField("dstPort", dataPathEndpoints.dstPort());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/DataPathSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/DataPathSerializer.java
new file mode 100644
index 0000000..d150c37
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/DataPathSerializer.java
@@ -0,0 +1,32 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.DataPath;
+import net.floodlightcontroller.util.FlowEntry;
+
+/**
+ * Serialize a DataPath as a string.
+ */
+public class DataPathSerializer extends JsonSerializer<DataPath> {
+
+ @Override
+ public void serialize(DataPath dataPath,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("srcPort", dataPath.srcPort());
+ jGen.writeArrayFieldStart("flowEntries");
+ for (FlowEntry fe: dataPath.flowEntries()) {
+ jGen.writeObject(fe);
+ }
+ jGen.writeEndArray();
+ jGen.writeObjectField("dstPort", dataPath.dstPort());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java
new file mode 100644
index 0000000..2b71690
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.Dpid;
+
+/**
+ * Serialize a DPID as a string.
+ */
+public class DpidSerializer extends JsonSerializer<Dpid> {
+
+ @Override
+ public void serialize(Dpid dpid, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(dpid.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryActionsSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryActionsSerializer.java
new file mode 100644
index 0000000..bd5970d
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryActionsSerializer.java
@@ -0,0 +1,24 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowEntryActions;
+
+/**
+ * Serialize a FlowEntryActions as a string.
+ */
+public class FlowEntryActionsSerializer extends JsonSerializer<FlowEntryActions> {
+
+ @Override
+ public void serialize(FlowEntryActions flowEntryActions,
+ JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeObject(flowEntryActions);
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryErrorStateSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryErrorStateSerializer.java
new file mode 100644
index 0000000..2518e86
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryErrorStateSerializer.java
@@ -0,0 +1,26 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowEntryErrorState;
+
+/**
+ * Serialize a Flow Entry Error State as a string.
+ */
+public class FlowEntryErrorStateSerializer extends JsonSerializer<FlowEntryErrorState> {
+
+ @Override
+ public void serialize(FlowEntryErrorState flowEntryErrorState,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeNumberField("type", flowEntryErrorState.type());
+ jGen.writeNumberField("code", flowEntryErrorState.code());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryIdSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryIdSerializer.java
new file mode 100644
index 0000000..4b6583c
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryIdSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowEntryId;
+
+/**
+ * Serialize a Flow Entry ID as a hexadecimal string.
+ */
+public class FlowEntryIdSerializer extends JsonSerializer<FlowEntryId> {
+
+ @Override
+ public void serialize(FlowEntryId flowEntryId, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(flowEntryId.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java
new file mode 100644
index 0000000..0de3b08
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java
@@ -0,0 +1,28 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowEntryMatch;
+
+/**
+ * Serialize a FlowEntryMatch as a string.
+ */
+public class FlowEntryMatchSerializer extends JsonSerializer<FlowEntryMatch> {
+
+ @Override
+ public void serialize(FlowEntryMatch flowEntryMatch,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("srcMac", flowEntryMatch.srcMac());
+ jGen.writeObjectField("dstMac", flowEntryMatch.dstMac());
+ jGen.writeObjectField("srcIPv4Net", flowEntryMatch.srcIPv4Net());
+ jGen.writeObjectField("dstIPv4Net", flowEntryMatch.dstIPv4Net());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntrySerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntrySerializer.java
new file mode 100644
index 0000000..9912d55
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntrySerializer.java
@@ -0,0 +1,37 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowEntry;
+
+/**
+ * Serialize a FlowEntry as a string.
+ */
+public class FlowEntrySerializer extends JsonSerializer<FlowEntry> {
+
+ @Override
+ public void serialize(FlowEntry flowEntry,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("flowEntryId", flowEntry.flowEntryId());
+ jGen.writeObjectField("flowEntryMatch", flowEntry.flowEntryMatch());
+ jGen.writeObjectField("flowEntryActions",
+ flowEntry.flowEntryActions());
+ jGen.writeObjectField("dpid", flowEntry.dpid());
+ jGen.writeObjectField("inPort", flowEntry.inPort());
+ jGen.writeObjectField("outPort", flowEntry.outPort());
+ jGen.writeObjectField("flowEntryUserState",
+ flowEntry.flowEntryUserState());
+ jGen.writeObjectField("flowEntrySwitchState",
+ flowEntry.flowEntrySwitchState());
+ jGen.writeObjectField("flowEntryErrorState",
+ flowEntry.flowEntryErrorState());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java
new file mode 100644
index 0000000..0e69273
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowId;
+
+/**
+ * Serialize a Flow ID as a hexadecimal string.
+ */
+public class FlowIdSerializer extends JsonSerializer<FlowId> {
+
+ @Override
+ public void serialize(FlowId flowId, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(flowId.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowPathSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowPathSerializer.java
new file mode 100644
index 0000000..a6a5405
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowPathSerializer.java
@@ -0,0 +1,27 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.FlowPath;
+
+/**
+ * Serialize a FlowPath as a string.
+ */
+public class FlowPathSerializer extends JsonSerializer<FlowPath> {
+
+ @Override
+ public void serialize(FlowPath flowPath,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("flowId", flowPath.flowId());
+ jGen.writeObjectField("installerId", flowPath.installerId());
+ jGen.writeObjectField("dataPath", flowPath.dataPath());
+ jGen.writeEndObject();
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java
new file mode 100644
index 0000000..fc71dd3
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.IPv4Net;
+
+/**
+ * Serialize an IPv4Net address as a string.
+ */
+public class IPv4NetSerializer extends JsonSerializer<IPv4Net> {
+
+ @Override
+ public void serialize(IPv4Net ipv4Net, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(ipv4Net.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java
new file mode 100644
index 0000000..68e952c
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.IPv4;
+
+/**
+ * Serialize an IPv4 address as a string.
+ */
+public class IPv4Serializer extends JsonSerializer<IPv4> {
+
+ @Override
+ public void serialize(IPv4 ipv4, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(ipv4.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java
new file mode 100644
index 0000000..0f59dc2
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.IPv6Net;
+
+/**
+ * Serialize an IPv6Net address as a string.
+ */
+public class IPv6NetSerializer extends JsonSerializer<IPv6Net> {
+
+ @Override
+ public void serialize(IPv6Net ipv6Net, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(ipv6Net.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java
new file mode 100644
index 0000000..dabbfa4
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.IPv6;
+
+/**
+ * Serialize an IPv6 address as a string.
+ */
+public class IPv6Serializer extends JsonSerializer<IPv6> {
+
+ @Override
+ public void serialize(IPv6 ipv6, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeString(ipv6.toString());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java
new file mode 100644
index 0000000..e79c600
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java
@@ -0,0 +1,23 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.Port;
+
+/**
+ * Serialize a Port as a string.
+ */
+public class PortSerializer extends JsonSerializer<Port> {
+
+ @Override
+ public void serialize(Port port, JsonGenerator jGen,
+ SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeNumber(port.value());
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/SwitchPortSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/SwitchPortSerializer.java
new file mode 100644
index 0000000..8abbb52
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/SwitchPortSerializer.java
@@ -0,0 +1,26 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import net.floodlightcontroller.util.SwitchPort;
+
+/**
+ * Serialize a SwitchPort as a string.
+ */
+public class SwitchPortSerializer extends JsonSerializer<SwitchPort> {
+
+ @Override
+ public void serialize(SwitchPort switchPort,
+ JsonGenerator jGen, SerializerProvider serializer)
+ throws IOException, JsonProcessingException {
+ jGen.writeStartObject();
+ jGen.writeObjectField("dpid", switchPort.dpid());
+ jGen.writeObjectField("port", switchPort.port());
+ jGen.writeEndObject();
+ }
+}