Leftover follow-up commit for "1c8f47754241fea8b9c1463c08539ec31638a5de":
* Use the "@JsonProperty()" annotation to serialize/deserialize
objects that don't require any specialized processing.
Use "@JsonSerialize" and "@JsonDeserialize" only for objects
that need more specialized processing.
* Remove FooSerializer JSON classes that are not used/needed anymore.
* Update the implementation of remaining FooSerializer classes,
and associated Foo classes.
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
index f32d124..feb43d3 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/AddFlowResource.java
@@ -1,9 +1,15 @@
package net.floodlightcontroller.flowcache.web;
+import java.io.IOException;
+
import net.floodlightcontroller.flowcache.IFlowService;
import net.floodlightcontroller.util.FlowId;
import net.floodlightcontroller.util.FlowPath;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -26,14 +32,29 @@
return result;
}
+ //
// Extract the arguments
+ // NOTE: The "flow" is specified in JSON format.
+ //
+ ObjectMapper mapper = new ObjectMapper();
String flowPathStr = (String) getRequestAttributes().get("flow");
- FlowPath flowPath = new FlowPath(flowPathStr);
-
+ FlowPath flowPath = null;
log.debug("Add Flow Path: " + flowPathStr);
+ try {
+ flowPath = mapper.readValue(flowPathStr, FlowPath.class);
+ } catch (JsonGenerationException e) {
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- if (flowService.addFlow(flowPath, result) != true) {
- result = new FlowId(); // Error: Empty Flow Id
+ // Process the request
+ if (flowPath != null) {
+ if (flowService.addFlow(flowPath, result) != true) {
+ result = new FlowId(); // Error: Return empty Flow Id
+ }
}
return result;
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
index cefad18..f418c1e 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/DeleteFlowResource.java
@@ -27,12 +27,11 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
-
+ FlowId flowId = new FlowId(flowIdStr);
log.debug("Delete Flow Id: " + flowIdStr);
+ // Process the request
result = flowService.deleteFlow(flowId);
-
- return result;
+ return result;
}
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
index 4e96c0c..c485d91 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
@@ -9,7 +9,6 @@
import net.floodlightcontroller.util.Port;
import net.floodlightcontroller.util.SwitchPort;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -40,9 +39,9 @@
log.debug("Get All Flows Endpoints: " + srcDpidStr + "--" +
srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
- Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Dpid srcDpid = new Dpid(srcDpidStr);
Port srcPort = new Port(Short.parseShort(srcPortStr));
- Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
Port dstPort = new Port(Short.parseShort(dstPortStr));
SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
index 5bf3a50..deb4d04 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetAllFlowsResource.java
@@ -30,6 +30,8 @@
log.debug("Get All Flows Endpoints");
flowService.getAllFlows(result);
+ FlowPath flowPath = new FlowPath();
+ result.add(flowPath);
return result;
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
index 2863c79..d5b2730 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByIdResource.java
@@ -4,7 +4,6 @@
import net.floodlightcontroller.util.FlowId;
import net.floodlightcontroller.util.FlowPath;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -28,7 +27,7 @@
// Extract the arguments
String flowIdStr = (String) getRequestAttributes().get("flow-id");
- FlowId flowId = new FlowId(HexString.toLong(flowIdStr));
+ FlowId flowId = new FlowId(flowIdStr);
log.debug("Get Flow Id: " + flowIdStr);
diff --git a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
index 6b5f7f4..cb4e6ef 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/web/GetFlowByInstallerIdResource.java
@@ -8,7 +8,6 @@
import net.floodlightcontroller.util.Port;
import net.floodlightcontroller.util.SwitchPort;
-import org.openflow.util.HexString;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -42,9 +41,9 @@
dstDpidStr + "--" + dstPortStr);
CallerId installerId = new CallerId(installerIdStr);
- Dpid srcDpid = new Dpid(HexString.toLong(srcDpidStr));
+ Dpid srcDpid = new Dpid(srcDpidStr);
Port srcPort = new Port(Short.parseShort(srcPortStr));
- Dpid dstDpid = new Dpid(HexString.toLong(dstDpidStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
Port dstPort = new Port(Short.parseShort(dstPortStr));
SwitchPort srcSwitchPort = new SwitchPort(srcDpid, srcPort);
SwitchPort dstSwitchPort = new SwitchPort(dstDpid, dstPort);
diff --git a/src/main/java/net/floodlightcontroller/util/CallerId.java b/src/main/java/net/floodlightcontroller/util/CallerId.java
index 200b9e0..ade0f0d 100644
--- a/src/main/java/net/floodlightcontroller/util/CallerId.java
+++ b/src/main/java/net/floodlightcontroller/util/CallerId.java
@@ -1,14 +1,10 @@
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;
@@ -31,6 +27,7 @@
*
* @return the value of the Caller ID.
*/
+ @JsonProperty("value")
public String value() { return value; }
/**
@@ -38,6 +35,7 @@
*
* @param value the value to set.
*/
+ @JsonProperty("value")
public void setValue(String value) {
this.value = value;
}
diff --git a/src/main/java/net/floodlightcontroller/util/DataPath.java b/src/main/java/net/floodlightcontroller/util/DataPath.java
index ad6cdb8..9ec9380 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPath.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPath.java
@@ -4,15 +4,12 @@
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
@@ -29,6 +26,7 @@
*
* @return the data path source port.
*/
+ @JsonProperty("srcPort")
public SwitchPort srcPort() { return srcPort; }
/**
@@ -36,6 +34,7 @@
*
* @param srcPort the data path source port to set.
*/
+ @JsonProperty("srcPort")
public void setSrcPort(SwitchPort srcPort) {
this.srcPort = srcPort;
}
@@ -45,6 +44,7 @@
*
* @return the data path destination port.
*/
+ @JsonProperty("dstPort")
public SwitchPort dstPort() { return dstPort; }
/**
@@ -52,6 +52,7 @@
*
* @param dstPort the data path destination port to set.
*/
+ @JsonProperty("dstPort")
public void setDstPort(SwitchPort dstPort) {
this.dstPort = dstPort;
}
@@ -61,6 +62,7 @@
*
* @return the data path flow entries.
*/
+ @JsonProperty("flowEntries")
public ArrayList<FlowEntry> flowEntries() { return flowEntries; }
/**
@@ -68,6 +70,7 @@
*
* @param flowEntries the data path flow entries to set.
*/
+ @JsonProperty("flowEntries")
public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
this.flowEntries = flowEntries;
}
diff --git a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
index 92cf2dd..3ee88d1 100644
--- a/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
+++ b/src/main/java/net/floodlightcontroller/util/DataPathEndpoints.java
@@ -1,15 +1,12 @@
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
@@ -36,6 +33,7 @@
*
* @return the data path source port.
*/
+ @JsonProperty("srcPort")
public SwitchPort srcPort() { return srcPort; }
/**
@@ -43,6 +41,7 @@
*
* @param srcPort the data path source port to set.
*/
+ @JsonProperty("srcPort")
public void setSrcPort(SwitchPort srcPort) {
this.srcPort = srcPort;
}
@@ -52,6 +51,7 @@
*
* @return the data path destination port.
*/
+ @JsonProperty("dstPort")
public SwitchPort dstPort() { return dstPort; }
/**
@@ -59,6 +59,7 @@
*
* @param dstPort the data path destination port to set.
*/
+ @JsonProperty("dstPort")
public void setDstPort(SwitchPort dstPort) {
this.dstPort = dstPort;
}
diff --git a/src/main/java/net/floodlightcontroller/util/Dpid.java b/src/main/java/net/floodlightcontroller/util/Dpid.java
index 7787953..5af6bea 100644
--- a/src/main/java/net/floodlightcontroller/util/Dpid.java
+++ b/src/main/java/net/floodlightcontroller/util/Dpid.java
@@ -1,14 +1,17 @@
package net.floodlightcontroller.util;
import org.openflow.util.HexString;
+import net.floodlightcontroller.util.serializers.DpidDeserializer;
import net.floodlightcontroller.util.serializers.DpidSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing a network switch DPID.
*/
+@JsonDeserialize(using=DpidDeserializer.class)
@JsonSerialize(using=DpidSerializer.class)
public class Dpid {
static public long UNKNOWN = 0;
@@ -32,6 +35,15 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(String value) {
+ this.value = HexString.toLong(value);
+ }
+
+ /**
* Get the value of the DPID.
*
* @return the value of the DPID.
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntry.java b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
index 42ec935..dfb8f82 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntry.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntry.java
@@ -5,10 +5,8 @@
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).
@@ -38,7 +36,6 @@
* 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
@@ -64,6 +61,7 @@
*
* @return the Flow Entry ID.
*/
+ @JsonProperty("flowEntryId")
public FlowEntryId flowEntryId() { return flowEntryId; }
/**
@@ -71,6 +69,7 @@
*
* @param flowEntryId the Flow Entry ID to set.
*/
+ @JsonProperty("flowEntryId")
public void setFlowEntryId(FlowEntryId flowEntryId) {
this.flowEntryId = flowEntryId;
}
@@ -80,6 +79,7 @@
*
* @return the Flow Entry Match.
*/
+ @JsonProperty("flowEntryMatch")
public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; }
/**
@@ -87,6 +87,7 @@
*
* @param flowEntryMatch the Flow Entry Match to set.
*/
+ @JsonProperty("flowEntryMatch")
public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) {
this.flowEntryMatch = flowEntryMatch;
}
@@ -96,6 +97,7 @@
*
* @return the Flow Entry Actions.
*/
+ @JsonProperty("flowEntryActions")
public FlowEntryActions flowEntryActions() { return flowEntryActions; }
/**
@@ -103,6 +105,7 @@
*
* @param flowEntryActions the Flow Entry Actions to set.
*/
+ @JsonProperty("flowEntryActions")
public void setFlowEntryActions(FlowEntryActions flowEntryActions) {
this.flowEntryActions = flowEntryActions;
}
@@ -112,6 +115,7 @@
*
* @return the Switch DPID.
*/
+ @JsonProperty("dpid")
public Dpid dpid() { return dpid; }
/**
@@ -119,6 +123,7 @@
*
* @param dpid the Switch DPID to set.
*/
+ @JsonProperty("dpid")
public void setDpid(Dpid dpid) {
this.dpid = dpid;
}
@@ -128,6 +133,7 @@
*
* @return the Switch incoming port.
*/
+ @JsonProperty("inPort")
public Port inPort() { return inPort; }
/**
@@ -135,6 +141,7 @@
*
* @param inPort the Switch incoming port to set.
*/
+ @JsonProperty("inPort")
public void setInPort(Port inPort) {
this.inPort = inPort;
}
@@ -144,6 +151,7 @@
*
* @return the Switch outgoing port.
*/
+ @JsonProperty("outPort")
public Port outPort() { return outPort; }
/**
@@ -151,6 +159,7 @@
*
* @param outPort the Switch outgoing port to set.
*/
+ @JsonProperty("outPort")
public void setOutPort(Port outPort) {
this.outPort = outPort;
}
@@ -160,6 +169,7 @@
*
* @return the Flow Entry User state.
*/
+ @JsonProperty("flowEntryUserState")
public FlowEntryUserState flowEntryUserState() {
return flowEntryUserState;
}
@@ -169,6 +179,7 @@
*
* @param flowEntryUserState the Flow Entry User state to set.
*/
+ @JsonProperty("flowEntryUserState")
public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) {
this.flowEntryUserState = flowEntryUserState;
}
@@ -181,6 +192,7 @@
*
* @return the Flow Entry Switch state.
*/
+ @JsonProperty("flowEntrySwitchState")
public FlowEntrySwitchState flowEntrySwitchState() {
return flowEntrySwitchState;
}
@@ -193,6 +205,7 @@
*
* @param flowEntrySwitchState the Flow Entry Switch state to set.
*/
+ @JsonProperty("flowEntrySwitchState")
public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) {
this.flowEntrySwitchState = flowEntrySwitchState;
}
@@ -202,6 +215,7 @@
*
* @return the Flow Entry Error state.
*/
+ @JsonProperty("flowEntryErrorState")
public FlowEntryErrorState flowEntryErrorState() {
return flowEntryErrorState;
}
@@ -211,6 +225,7 @@
*
* @param flowEntryErrorState the Flow Entry Error state to set.
*/
+ @JsonProperty("flowEntryErrorState")
public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) {
this.flowEntryErrorState = flowEntryErrorState;
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java b/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
index b683d2c..4d17de8 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryActions.java
@@ -1,9 +1,6 @@
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.
@@ -13,7 +10,6 @@
* 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 f9ca8ba..bf1708d 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryErrorState.java
@@ -1,14 +1,10 @@
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)
@@ -37,16 +33,38 @@
*
* @return the error type.
*/
+ @JsonProperty("type")
public short type() { return type; }
/**
+ * Set the error type.
+ *
+ * @param type the error type to use.
+ */
+ @JsonProperty("type")
+ public void setType(short type) {
+ this.type = type;
+ }
+
+ /**
* Get the error code.
*
* @return the error code.
*/
+ @JsonProperty("code")
public short code() { return code; }
/**
+ * Set the error code.
+ *
+ * @param code the error code to use.
+ */
+ @JsonProperty("code")
+ public void setCode(short code) {
+ this.code = code;
+ }
+
+ /**
* Set the values of the error type and code.
*
* @param type the error type to use.
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryId.java b/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
index bf1fc7d..0874bdb 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryId.java
@@ -1,13 +1,16 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowEntryIdDeserializer;
import net.floodlightcontroller.util.serializers.FlowEntryIdSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing a Flow Entry ID.
*/
+@JsonDeserialize(using=FlowEntryIdDeserializer.class)
@JsonSerialize(using=FlowEntryIdSerializer.class)
public class FlowEntryId {
private long value;
@@ -29,6 +32,15 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public FlowEntryId(String value) {
+ this.value = Long.decode(value);
+ }
+
+ /**
* Get the value of the Flow Entry ID.
*
* @return the value of the Flow Entry ID.
diff --git a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
index 0e3775e..9bd3bea 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowEntryMatch.java
@@ -2,10 +2,8 @@
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.
@@ -19,7 +17,6 @@
* 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
@@ -37,6 +34,7 @@
*
* @return the matching source MAC address.
*/
+ @JsonProperty("srcMac")
public MACAddress srcMac() { return srcMac; }
/**
@@ -44,6 +42,7 @@
*
* @param srcMac the matching source MAC address to set.
*/
+ @JsonProperty("srcMac")
public void setSrcMac(MACAddress srcMac) {
this.srcMac = srcMac;
}
@@ -53,6 +52,7 @@
*
* @return the matching destination MAC address.
*/
+ @JsonProperty("dstMac")
public MACAddress dstMac() { return dstMac; }
/**
@@ -60,6 +60,7 @@
*
* @param dstMac the matching destination MAC address to set.
*/
+ @JsonProperty("dstMac")
public void setDstMac(MACAddress dstMac) {
this.dstMac = dstMac;
}
@@ -69,6 +70,7 @@
*
* @return the matching source IPv4 prefix.
*/
+ @JsonProperty("srcIPv4Net")
public IPv4Net srcIPv4Net() { return srcIPv4Net; }
/**
@@ -76,6 +78,7 @@
*
* @param srcIPv4Net the matching source IPv4 prefix to set.
*/
+ @JsonProperty("srcIPv4Net")
public void setSrcIPv4Net(IPv4Net srcIPv4Net) {
this.srcIPv4Net = srcIPv4Net;
}
@@ -85,6 +88,7 @@
*
* @return the matching destination IPv4 prefix.
*/
+ @JsonProperty("dstIPv4Net")
public IPv4Net dstIPv4Net() { return dstIPv4Net; }
/**
@@ -92,6 +96,7 @@
*
* @param srcIPv4Net the matching destination IPv4 prefix to set.
*/
+ @JsonProperty("dstIPv4Net")
public void setDstIPv4Net(IPv4Net dstIPv4Net) {
this.dstIPv4Net = dstIPv4Net;
}
diff --git a/src/main/java/net/floodlightcontroller/util/FlowId.java b/src/main/java/net/floodlightcontroller/util/FlowId.java
index a8beaa0..297c0c4 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowId.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowId.java
@@ -1,13 +1,16 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.FlowIdDeserializer;
import net.floodlightcontroller.util.serializers.FlowIdSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing a Flow ID.
*/
+@JsonDeserialize(using=FlowIdDeserializer.class)
@JsonSerialize(using=FlowIdSerializer.class)
public class FlowId {
private long value;
@@ -29,6 +32,15 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public FlowId(String value) {
+ this.value = Long.decode(value);
+ }
+
+ /**
* Get the value of the Flow ID.
*
* @return the value of the Flow ID.
diff --git a/src/main/java/net/floodlightcontroller/util/FlowPath.java b/src/main/java/net/floodlightcontroller/util/FlowPath.java
index f91bb4a..5b3bbd1 100644
--- a/src/main/java/net/floodlightcontroller/util/FlowPath.java
+++ b/src/main/java/net/floodlightcontroller/util/FlowPath.java
@@ -3,15 +3,12 @@
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
@@ -24,17 +21,11 @@
}
/**
- * Constructor from a string.
- */
- public FlowPath(String str) {
- // TODO: Implement it.
- }
-
- /**
* Get the flow path Flow ID.
*
* @return the flow path Flow ID.
*/
+ @JsonProperty("flowId")
public FlowId flowId() { return flowId; }
/**
@@ -42,6 +33,7 @@
*
* @param flowId the flow path Flow ID to set.
*/
+ @JsonProperty("flowId")
public void setFlowId(FlowId flowId) {
this.flowId = flowId;
}
@@ -51,6 +43,7 @@
*
* @return the Caller ID of the flow path installer.
*/
+ @JsonProperty("installerId")
public CallerId installerId() { return installerId; }
/**
@@ -58,6 +51,7 @@
*
* @param installerId the Caller ID of the flow path installer.
*/
+ @JsonProperty("installerId")
public void setInstallerId(CallerId installerId) {
this.installerId = installerId;
}
@@ -67,6 +61,7 @@
*
* @return the flow path's data path.
*/
+ @JsonProperty("dataPath")
public DataPath dataPath() { return dataPath; }
/**
@@ -74,6 +69,7 @@
*
* @param dataPath the flow path's data path to set.
*/
+ @JsonProperty("dataPath")
public void setDataPath(DataPath dataPath) {
this.dataPath = dataPath;
}
diff --git a/src/main/java/net/floodlightcontroller/util/IPv4.java b/src/main/java/net/floodlightcontroller/util/IPv4.java
index 3f4f350..ef3a1e5 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv4.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv4.java
@@ -1,13 +1,16 @@
package net.floodlightcontroller.util;
+import net.floodlightcontroller.util.serializers.IPv4Deserializer;
import net.floodlightcontroller.util.serializers.IPv4Serializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv4 address.
*/
+@JsonDeserialize(using=IPv4Deserializer.class)
@JsonSerialize(using=IPv4Serializer.class)
public class IPv4 {
private int value;
@@ -29,6 +32,24 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public IPv4(String value) {
+ String[] splits = value.split("\\.");
+ if (splits.length != 4)
+ throw new IllegalArgumentException("Specified IPv4 address must contain four " +
+ "numerical digits separated by '.'");
+
+ int result = 0;
+ for (int i = 0; i < 4; ++i) {
+ result |= Integer.valueOf(splits[i]) << ((3-i)*8);
+ }
+ this.value = result;
+ }
+
+ /**
* Get the value of the IPv4 address.
*
* @return the value of the IPv4 address.
diff --git a/src/main/java/net/floodlightcontroller/util/IPv4Net.java b/src/main/java/net/floodlightcontroller/util/IPv4Net.java
index f64ccb8..824e3e2 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv4Net.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv4Net.java
@@ -1,14 +1,17 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.IPv4;
+import net.floodlightcontroller.util.serializers.IPv4NetDeserializer;
import net.floodlightcontroller.util.serializers.IPv4NetSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv4 network address.
*/
+@JsonDeserialize(using=IPv4NetDeserializer.class)
@JsonSerialize(using=IPv4NetSerializer.class)
public class IPv4Net {
private IPv4 address; // The IPv4 address
@@ -33,6 +36,21 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public IPv4Net(String value) {
+ String[] splits = value.split("/");
+ if (splits.length != 2) {
+ throw new IllegalArgumentException("Specified IPv4Net address must contain an IPv4 " +
+ "address and a prefix length separated by '/'");
+ }
+ this.address = new IPv4(splits[0]);
+ this.prefixLen = Short.decode(splits[1]);
+ }
+
+ /**
* Get the address value of the IPv4Net address.
*
* @return the address value of the IPv4Net address.
@@ -40,6 +58,15 @@
public IPv4 address() { return address; }
/**
+ * Set the address value of the IPv4Net address.
+ *
+ * @param address the address to use.
+ */
+ public void setAddress(IPv4 address) {
+ this.address = address;
+ }
+
+ /**
* Get the prefix length value of the IPv4Net address.
*
* @return the prefix length value of the IPv4Net address.
@@ -47,6 +74,15 @@
public short prefixLen() { return prefixLen; }
/**
+ * Set the prefix length value of the IPv4Net address.
+ *
+ * @param prefixLen the prefix length to use.
+ */
+ public void setPrefixLen(short prefixLen) {
+ this.prefixLen = prefixLen;
+ }
+
+ /**
* Set the value of the IPv4Net address.
*
* @param address the address to use.
diff --git a/src/main/java/net/floodlightcontroller/util/IPv6.java b/src/main/java/net/floodlightcontroller/util/IPv6.java
index d4461c0..eda4502 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv6.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv6.java
@@ -1,14 +1,17 @@
package net.floodlightcontroller.util;
import org.openflow.util.HexString;
+import net.floodlightcontroller.util.serializers.IPv6Deserializer;
import net.floodlightcontroller.util.serializers.IPv6Serializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv6 address.
*/
+@JsonDeserialize(using=IPv6Deserializer.class)
@JsonSerialize(using=IPv6Serializer.class)
public class IPv6 {
private long valueHigh; // The higher (more significant) 64 bits
@@ -34,6 +37,17 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public IPv6(String value) {
+ // TODO: Implement it!
+ this.valueHigh = 0;
+ this.valueLow = 0;
+ }
+
+ /**
* Get the value of the higher (more significant) 64 bits of the address.
*
* @return the value of the higher (more significant) 64 bits of the
@@ -42,6 +56,15 @@
public long valueHigh() { return valueHigh; }
/**
+ * Set the value of the higher (more significant) 64 bits of the address.
+ *
+ * @param valueHigh the higher (more significant) 64 bits of the address.
+ */
+ public void setValueHigh(long valueHigh) {
+ this.valueHigh = valueHigh;
+ }
+
+ /**
* Get the value of the lower (less significant) 64 bits of the address.
*
* @return the value of the lower (less significant) 64 bits of the
@@ -50,6 +73,15 @@
public long valueLow() { return valueLow; }
/**
+ * Get the value of the lower (less significant) 64 bits of the address.
+ *
+ * @param valueLow the lower (less significant) 64 bits of the address.
+ */
+ public void setValueLow(long valueLow) {
+ this.valueLow = valueLow;
+ }
+
+ /**
* Set the value of the IPv6 address.
*
* @param valueHigh the higher (more significant) 64 bits of the address.
diff --git a/src/main/java/net/floodlightcontroller/util/IPv6Net.java b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
index 1942293..b6f7d67 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv6Net.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
@@ -1,14 +1,17 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.IPv6;
+import net.floodlightcontroller.util.serializers.IPv6NetDeserializer;
import net.floodlightcontroller.util.serializers.IPv6NetSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv6 network address.
*/
+@JsonDeserialize(using=IPv6NetDeserializer.class)
@JsonSerialize(using=IPv6NetSerializer.class)
public class IPv6Net {
private IPv6 address; // The IPv6 address
@@ -33,6 +36,21 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public IPv6Net(String value) {
+ String[] splits = value.split("/");
+ if (splits.length != 2) {
+ throw new IllegalArgumentException("Specified IPv6Net address must contain an IPv6 " +
+ "address and a prefix length separated by '/'");
+ }
+ this.address = new IPv6(splits[0]);
+ this.prefixLen = Short.decode(splits[1]);
+ }
+
+ /**
* Get the address value of the IPv6Net address.
*
* @return the address value of the IPv6Net address.
@@ -40,6 +58,15 @@
public IPv6 address() { return address; }
/**
+ * Set the address value of the IPv6Net address.
+ *
+ * @param address the address to use.
+ */
+ public void setAddress(IPv6 address) {
+ this.address = address;
+ }
+
+ /**
* Get the prefix length value of the IPv6Net address.
*
* @return the prefix length value of the IPv6Net address.
@@ -47,6 +74,15 @@
public short prefixLen() { return prefixLen; }
/**
+ * Set the prefix length value of the IPv6Net address.
+ *
+ * @param prefixLen the prefix length to use.
+ */
+ public void setPrefixLen(short prefixLen) {
+ this.prefixLen = prefixLen;
+ }
+
+ /**
* Set the value of the IPv6Net address.
*
* @param address the address to use.
diff --git a/src/main/java/net/floodlightcontroller/util/Port.java b/src/main/java/net/floodlightcontroller/util/Port.java
index 0bfb07a..52fdf50 100644
--- a/src/main/java/net/floodlightcontroller/util/Port.java
+++ b/src/main/java/net/floodlightcontroller/util/Port.java
@@ -1,14 +1,10 @@
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;
@@ -33,6 +29,7 @@
*
* @return the value of the port.
*/
+ @JsonProperty("value")
public short value() { return value; }
/**
@@ -40,6 +37,7 @@
*
* @param value the value to set.
*/
+ @JsonProperty("value")
public void setValue(short value) {
this.value = value;
}
diff --git a/src/main/java/net/floodlightcontroller/util/SwitchPort.java b/src/main/java/net/floodlightcontroller/util/SwitchPort.java
index 462cdfb..027b681 100644
--- a/src/main/java/net/floodlightcontroller/util/SwitchPort.java
+++ b/src/main/java/net/floodlightcontroller/util/SwitchPort.java
@@ -2,15 +2,12 @@
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
@@ -37,16 +34,38 @@
*
* @return the DPID value of the Switch-Port.
*/
+ @JsonProperty("dpid")
public Dpid dpid() { return dpid; }
/**
+ * Set the DPID value of the Switch-Port.
+ *
+ * @param dpid the DPID to use.
+ */
+ @JsonProperty("dpid")
+ public void setDpid(Dpid dpid) {
+ this.dpid = dpid;
+ }
+
+ /**
* Get the port value of the Switch-Port.
*
* @return the port value of the Switch-Port.
*/
+ @JsonProperty("port")
public Port port() { return port; }
/**
+ * Set the port value of the Switch-Port.
+ *
+ * @param port the port to use.
+ */
+ @JsonProperty("port")
+ public void setPort(Port port) {
+ this.port = port;
+ }
+
+ /**
* Set the DPID and port values of the Switch-Port.
*
* @param dpid the DPID to use.
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java
index 2b71690..06fab62 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/DpidSerializer.java
@@ -18,6 +18,8 @@
public void serialize(Dpid dpid, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(dpid.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", dpid.toString());
+ jGen.writeEndObject();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java
index 0e69273..6f1a6f6 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdSerializer.java
@@ -18,6 +18,8 @@
public void serialize(FlowId flowId, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(flowId.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", flowId.toString());
+ jGen.writeEndObject();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java
index fc71dd3..5c5e1d0 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetSerializer.java
@@ -18,6 +18,8 @@
public void serialize(IPv4Net ipv4Net, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(ipv4Net.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", ipv4Net.toString());
+ jGen.writeEndObject();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java
index 68e952c..ba7d825 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Serializer.java
@@ -18,6 +18,8 @@
public void serialize(IPv4 ipv4, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(ipv4.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", ipv4.toString());
+ jGen.writeEndObject();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java
index 0f59dc2..fc5d262 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetSerializer.java
@@ -18,6 +18,8 @@
public void serialize(IPv6Net ipv6Net, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(ipv6Net.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", ipv6Net.toString());
+ jGen.writeEndObject();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java
index dabbfa4..0b08a63 100644
--- a/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Serializer.java
@@ -18,6 +18,8 @@
public void serialize(IPv6 ipv6, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
- jGen.writeString(ipv6.toString());
+ jGen.writeStartObject();
+ jGen.writeStringField("value", ipv6.toString());
+ jGen.writeEndObject();
}
}