Merged role changer code into master
diff --git a/cassandra.titan b/cassandra.titan
new file mode 100644
index 0000000..ef6f3ae
--- /dev/null
+++ b/cassandra.titan
@@ -0,0 +1,3 @@
+storage.backend=cassandra
+storage.hostname=localhost
+storage.keyspace=onos
diff --git a/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java b/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
index a3eb830..b16e4a9 100644
--- a/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
+++ b/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
@@ -8,6 +8,8 @@
import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.floodlightcontroller.routing.Link;
import net.floodlightcontroller.topology.NodePortTuple;
+import net.floodlightcontroller.util.DataPath;
+import net.floodlightcontroller.util.SwitchPort;
public interface INetMapTopologyService extends INetMapService {
@@ -31,8 +33,8 @@
}
public interface ITopoRouteService extends IFloodlightService {
- List<NodePortTuple> getShortestPath(NodePortTuple src, NodePortTuple dest);
- Boolean routeExists(NodePortTuple src, NodePortTuple dest);
+ DataPath getShortestPath(SwitchPort src, SwitchPort dest);
+ Boolean routeExists(SwitchPort src, SwitchPort dest);
}
public interface ITopoFlowService {
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/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
index df42075..6763c23 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -606,6 +606,10 @@
if (!isReverse && autoPortFastFeature && isFastPort(sw, port))
return;
+ // FIXME ONOS does not support BSN packets
+ if (!isStandard) {
+ return;
+ }
if (log.isTraceEnabled()) {
log.trace("Sending LLDP packet out of swich: {}, port: {}",
sw, port);
diff --git a/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java b/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
index 6d50602..f979cc7 100644
--- a/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
+++ b/src/main/java/net/floodlightcontroller/routing/TopoRouteService.java
@@ -13,7 +13,11 @@
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.core.INetMapTopologyService.ITopoRouteService;
-import net.floodlightcontroller.topology.NodePortTuple;
+import net.floodlightcontroller.util.DataPath;
+import net.floodlightcontroller.util.Dpid;
+import net.floodlightcontroller.util.FlowEntry;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
import org.openflow.util.HexString;
@@ -87,14 +91,17 @@
SwitchStorageImpl swStore = store.get();
@Override
- public List<NodePortTuple> getShortestPath(NodePortTuple src,
- NodePortTuple dest) {
- List<NodePortTuple> result_list = new ArrayList<NodePortTuple>();
+ public DataPath getShortestPath(SwitchPort src, SwitchPort dest) {
+ DataPath result_data_path = new DataPath();
+
+ // Initialize the source and destination in the data path to return
+ result_data_path.setSrcPort(src);
+ result_data_path.setDstPort(dest);
TitanGraph titanGraph = swStore.graph;
- String dpid_src = HexString.toHexString(src.getNodeId());
- String dpid_dest = HexString.toHexString(dest.getNodeId());
+ String dpid_src = src.dpid().toString();
+ String dpid_dest = dest.dpid().toString();
//
// Implement the Shortest Path between two vertices by using
@@ -120,16 +127,18 @@
//
// Test whether we are computing a path from/to the same DPID.
- // If "yes", then just list the "src" and "dest" in the return
- // result.
+ // If "yes", then just add a single flow entry in the return result.
// NOTE: The return value will change in the future to return
// a single hop/entry instead of two. Currently, we need
// both entries to capture the source and destination ports.
//
if (dpid_src.equals(dpid_dest)) {
- result_list.add(new NodePortTuple(src));
- result_list.add(new NodePortTuple(dest));
- return result_list;
+ FlowEntry flowEntry = new FlowEntry();
+ flowEntry.setDpid(src.dpid());
+ flowEntry.setInPort(src.port());
+ flowEntry.setOutPort(dest.port());
+ result_data_path.flowEntries().add(flowEntry);
+ return result_data_path;
}
//
@@ -151,11 +160,13 @@
}
//
- // Loop through the result and return the list
+ // Loop through the result and collect the list
// of <dpid, port> tuples.
//
long nodeId = 0;
short portId = 0;
+ Port inPort = new Port(src.port().value());
+ Port outPort = new Port();
for (ArrayList<Vertex> lv : results) {
int idx = 0;
for (Vertex v: lv) {
@@ -181,27 +192,48 @@
System.out.println("dpid: " + dpid);
}
- if (idx == 0) {
- idx++;
+ idx++;
+ if (idx == 1) {
continue;
}
- int mod = (idx - 1) % 3;
- if ((mod == 0) || (mod == 2)) {
- result_list.add(new NodePortTuple(nodeId, portId));
+ int mod = idx % 3;
+ if (mod == 0) {
+ // Setup the incoming port
+ inPort = new Port(portId);
+ continue;
}
- idx++;
+ if (mod == 2) {
+ // Setup the outgoing port, and add the Flow Entry
+ outPort = new Port(portId);
+
+ FlowEntry flowEntry = new FlowEntry();
+ flowEntry.setDpid(new Dpid(nodeId));
+ flowEntry.setInPort(inPort);
+ flowEntry.setOutPort(outPort);
+ result_data_path.flowEntries().add(flowEntry);
+ continue;
+ }
+ }
+
+ if (idx > 0) {
+ // Add the last Flow Entry
+ FlowEntry flowEntry = new FlowEntry();
+ flowEntry.setDpid(new Dpid(nodeId));
+ flowEntry.setInPort(inPort);
+ flowEntry.setOutPort(dest.port());
+ result_data_path.flowEntries().add(flowEntry);
}
}
- if (result_list.size() > 0)
- return result_list;
+ if (result_data_path.flowEntries().size() > 0)
+ return result_data_path;
return null;
}
@Override
- public Boolean routeExists(NodePortTuple src, NodePortTuple dest) {
- List<NodePortTuple> route = getShortestPath(src, dest);
- if (route != null)
+ public Boolean routeExists(SwitchPort src, SwitchPort dest) {
+ DataPath dataPath = getShortestPath(src, dest);
+ if (dataPath != null)
return true;
return false;
}
diff --git a/src/main/java/net/floodlightcontroller/topology/web/RouteResource.java b/src/main/java/net/floodlightcontroller/topology/web/RouteResource.java
index 3fa7510..20f39d4 100644
--- a/src/main/java/net/floodlightcontroller/topology/web/RouteResource.java
+++ b/src/main/java/net/floodlightcontroller/topology/web/RouteResource.java
@@ -6,6 +6,10 @@
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Route;
import net.floodlightcontroller.topology.NodePortTuple;
+import net.floodlightcontroller.util.DataPath;
+import net.floodlightcontroller.util.Dpid;
+import net.floodlightcontroller.util.Port;
+import net.floodlightcontroller.util.SwitchPort;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
@@ -18,7 +22,7 @@
protected static Logger log = LoggerFactory.getLogger(RouteResource.class);
@Get("json")
- public List<NodePortTuple> retrieve() {
+ public DataPath retrieve() {
ITopoRouteService topoRouteService =
(ITopoRouteService)getContext().getAttributes().
get(ITopoRouteService.class.getCanonicalName());
@@ -27,22 +31,22 @@
return null;
}
- String srcDpid = (String) getRequestAttributes().get("src-dpid");
- String srcPort = (String) getRequestAttributes().get("src-port");
- String dstDpid = (String) getRequestAttributes().get("dst-dpid");
- String dstPort = (String) getRequestAttributes().get("dst-port");
+ String srcDpidStr = (String) getRequestAttributes().get("src-dpid");
+ String srcPortStr = (String) getRequestAttributes().get("src-port");
+ String dstDpidStr = (String) getRequestAttributes().get("dst-dpid");
+ String dstPortStr = (String) getRequestAttributes().get("dst-port");
- log.debug( srcDpid + "--" + srcPort + "--" + dstDpid + "--" + dstPort);
+ log.debug( srcDpidStr + "--" + srcPortStr + "--" + dstDpidStr + "--" + dstPortStr);
- long longSrcDpid = HexString.toLong(srcDpid);
- short shortSrcPort = Short.parseShort(srcPort);
- long longDstDpid = HexString.toLong(dstDpid);
- short shortDstPort = Short.parseShort(dstPort);
+ Dpid srcDpid = new Dpid(srcDpidStr);
+ Port srcPort = new Port(Short.parseShort(srcPortStr));
+ Dpid dstDpid = new Dpid(dstDpidStr);
+ Port dstPort = new Port(Short.parseShort(dstPortStr));
- List<NodePortTuple> result =
- topoRouteService.getShortestPath(new NodePortTuple(longSrcDpid, shortSrcPort),
- new NodePortTuple(longDstDpid, shortDstPort));
- if ((result != null) && (result.size() > 0)) {
+ DataPath result =
+ topoRouteService.getShortestPath(new SwitchPort(srcDpid, srcPort),
+ new SwitchPort(dstDpid, dstPort));
+ if (result != null) {
return result;
} else {
log.debug("ERROR! no route found");
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..71e0a2f 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
@@ -22,6 +19,7 @@
* Default constructor.
*/
public DataPath() {
+ flowEntries = new ArrayList<FlowEntry>();
}
/**
@@ -29,6 +27,7 @@
*
* @return the data path source port.
*/
+ @JsonProperty("srcPort")
public SwitchPort srcPort() { return srcPort; }
/**
@@ -36,6 +35,7 @@
*
* @param srcPort the data path source port to set.
*/
+ @JsonProperty("srcPort")
public void setSrcPort(SwitchPort srcPort) {
this.srcPort = srcPort;
}
@@ -45,6 +45,7 @@
*
* @return the data path destination port.
*/
+ @JsonProperty("dstPort")
public SwitchPort dstPort() { return dstPort; }
/**
@@ -52,6 +53,7 @@
*
* @param dstPort the data path destination port to set.
*/
+ @JsonProperty("dstPort")
public void setDstPort(SwitchPort dstPort) {
this.dstPort = dstPort;
}
@@ -61,6 +63,7 @@
*
* @return the data path flow entries.
*/
+ @JsonProperty("flowEntries")
public ArrayList<FlowEntry> flowEntries() { return flowEntries; }
/**
@@ -68,6 +71,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..19bbf8f 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;
@@ -20,6 +16,15 @@
}
/**
+ * Constructor from another entry.
+ *
+ * @param other the other entry to use.
+ */
+ public Port(Port other) {
+ this.value = other.value();
+ }
+
+ /**
* Constructor from a long value.
*
* @param value the value to use.
@@ -33,6 +38,7 @@
*
* @return the value of the port.
*/
+ @JsonProperty("value")
public short value() { return value; }
/**
@@ -40,6 +46,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/CallerIdSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/CallerIdSerializer.java
deleted file mode 100644
index 9935324..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/CallerIdSerializer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-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
deleted file mode 100644
index e05c21d..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/DataPathEndpointsSerializer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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
deleted file mode 100644
index d150c37..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/DataPathSerializer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-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/DpidDeserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/DpidDeserializer.java
new file mode 100644
index 0000000..9297f56
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/DpidDeserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.Dpid;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize a DPID from a string.
+ */
+public class DpidDeserializer extends JsonDeserializer<Dpid> {
+
+ protected static Logger log = LoggerFactory.getLogger(DpidDeserializer.class);
+
+ @Override
+ public Dpid deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ Dpid dpid = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ dpid = new Dpid(value);
+ }
+ }
+ return dpid;
+ }
+}
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/FlowEntryActionsSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryActionsSerializer.java
deleted file mode 100644
index bd5970d..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryActionsSerializer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-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
deleted file mode 100644
index 2518e86..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryErrorStateSerializer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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/FlowEntryIdDeserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryIdDeserializer.java
new file mode 100644
index 0000000..e6481d5
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryIdDeserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.FlowEntryId;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize a Flow Entry ID from a string.
+ */
+public class FlowEntryIdDeserializer extends JsonDeserializer<FlowEntryId> {
+
+ protected static Logger log = LoggerFactory.getLogger(FlowEntryIdDeserializer.class);
+
+ @Override
+ public FlowEntryId deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ FlowEntryId flowEntryId = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ flowEntryId = new FlowEntryId(value);
+ }
+ }
+ return flowEntryId;
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java
deleted file mode 100644
index 0de3b08..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntryMatchSerializer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-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
deleted file mode 100644
index 9912d55..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowEntrySerializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-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/FlowIdDeserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdDeserializer.java
new file mode 100644
index 0000000..a7f53d4
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/FlowIdDeserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.FlowId;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize a Flow ID from a string.
+ */
+public class FlowIdDeserializer extends JsonDeserializer<FlowId> {
+
+ protected static Logger log = LoggerFactory.getLogger(FlowIdDeserializer.class);
+
+ @Override
+ public FlowId deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ FlowId flowId = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ flowId = new FlowId(value);
+ }
+ }
+ return flowId;
+ }
+}
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/FlowPathSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/FlowPathSerializer.java
deleted file mode 100644
index a6a5405..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/FlowPathSerializer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-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/IPv4Deserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Deserializer.java
new file mode 100644
index 0000000..7ce7d5c
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4Deserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.IPv4;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize an IPv4 from a string.
+ */
+public class IPv4Deserializer extends JsonDeserializer<IPv4> {
+
+ protected static Logger log = LoggerFactory.getLogger(IPv4Deserializer.class);
+
+ @Override
+ public IPv4 deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ IPv4 ipv4 = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ ipv4 = new IPv4(value);
+ }
+ }
+ return ipv4;
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetDeserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetDeserializer.java
new file mode 100644
index 0000000..e35fc80
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv4NetDeserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.IPv4Net;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize an IPv4Net from a string.
+ */
+public class IPv4NetDeserializer extends JsonDeserializer<IPv4Net> {
+
+ protected static Logger log = LoggerFactory.getLogger(IPv4NetDeserializer.class);
+
+ @Override
+ public IPv4Net deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ IPv4Net ipv4Net = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ ipv4Net = new IPv4Net(value);
+ }
+ }
+ return ipv4Net;
+ }
+}
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/IPv6Deserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Deserializer.java
new file mode 100644
index 0000000..6713f93
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6Deserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.IPv6;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize an IPv6 from a string.
+ */
+public class IPv6Deserializer extends JsonDeserializer<IPv6> {
+
+ protected static Logger log = LoggerFactory.getLogger(IPv6Deserializer.class);
+
+ @Override
+ public IPv6 deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ IPv6 ipv6 = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ ipv6 = new IPv6(value);
+ }
+ }
+ return ipv6;
+ }
+}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetDeserializer.java b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetDeserializer.java
new file mode 100644
index 0000000..596ee50
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/util/serializers/IPv6NetDeserializer.java
@@ -0,0 +1,43 @@
+package net.floodlightcontroller.util.serializers;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.ObjectCodec;
+import org.codehaus.jackson.map.JsonDeserializer;
+import org.codehaus.jackson.map.DeserializationContext;
+
+import net.floodlightcontroller.util.IPv6Net;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Deserialize an IPv6Net from a string.
+ */
+public class IPv6NetDeserializer extends JsonDeserializer<IPv6Net> {
+
+ protected static Logger log = LoggerFactory.getLogger(IPv6NetDeserializer.class);
+
+ @Override
+ public IPv6Net deserialize(JsonParser jp,
+ DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ IPv6Net ipv6Net = null;
+
+ jp.nextToken(); // Move to JsonToken.START_OBJECT
+ while (jp.nextToken() != JsonToken.END_OBJECT) {
+ String fieldname = jp.getCurrentName();
+ if ("value".equals(fieldname)) {
+ String value = jp.getText();
+ log.debug("Fieldname: " + fieldname + " Value: " + value);
+ ipv6Net = new IPv6Net(value);
+ }
+ }
+ return ipv6Net;
+ }
+}
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();
}
}
diff --git a/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java b/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java
deleted file mode 100644
index e79c600..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/PortSerializer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-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
deleted file mode 100644
index 8abbb52..0000000
--- a/src/main/java/net/floodlightcontroller/util/serializers/SwitchPortSerializer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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();
- }
-}
diff --git a/start-cassandra.sh b/start-cassandra.sh
index 011c09d..d670511 100755
--- a/start-cassandra.sh
+++ b/start-cassandra.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+# Set paths
+FL_HOME=`dirname $0`
CASSANDRA_DIR=${HOME}/apache-cassandra-1.1.4
LOGDIR=${HOME}/ONOS/onos-logs
CASSANDRA_LOG=$LOGDIR/cassandara.`hostname`.log
@@ -43,16 +45,18 @@
done
}
-#function deldb {
+function deldb {
# # Delete the berkeley db database
-# if [ -d "/tmp/cassandra.titan" ]; then
-# rm -rf /tmp/cassandra.titan
-# mkdir /tmp/cassandra.titan
-# fi
-#}
+ if [ -d "/tmp/cassandra.titan" ]; then
+ echo "deleting berkeley db dir"
+ sudo rm -rf /tmp/cassandra.titan
+ fi
+}
case "$1" in
start)
+ deldb
+ cp $FL_HOME/cassandra.titan /tmp
stop
start
;;
diff --git a/start-onos.sh b/start-onos.sh
index 19834af..0ef6ecd 100755
--- a/start-onos.sh
+++ b/start-onos.sh
@@ -103,10 +103,22 @@
mkdir /tmp/cassandra.titan
fi
}
+function check_db {
+ if [ -d "/tmp/cassandra.titan" ]; then
+ echo "Cassandra is running on local berkely db. Exitting"
+ exit
+ fi
+ n=`ps -edalf |grep java |grep apache-cassandra | wc -l`
+ if [ x$n != "x1" ]; then
+ echo "Cassandra is not running. Exitting"
+ exit
+ fi
+}
case "$1" in
start)
stop
+ check_db
start
;;
stop)
diff --git a/test-network/mininet/fat_tree.py b/test-network/mininet/fat_tree.py
new file mode 100755
index 0000000..c7e4178
--- /dev/null
+++ b/test-network/mininet/fat_tree.py
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+
+NWID="a"
+CONTROLLER_IP='127.0.0.1'
+
+"""
+Start up a Simple topology
+"""
+from mininet.net import Mininet
+from mininet.node import Controller, RemoteController
+from mininet.log import setLogLevel, info, error, warn, debug
+from mininet.cli import CLI
+from mininet.topo import Topo
+from mininet.util import quietRun
+from mininet.moduledeps import pathCheck
+from mininet.link import Link, TCLink
+
+from sys import exit
+import os.path
+from subprocess import Popen, STDOUT, PIPE
+
+import sys
+
+#import argparse
+
+class MyController( Controller ):
+ def __init__( self, name, ip=CONTROLLER_IP, port=6633, **kwargs):
+ """Init.
+ name: name to give controller
+ ip: the IP address where the remote controller is
+ listening
+ port: the port where the remote controller is listening"""
+ Controller.__init__( self, name, ip=ip, port=port, **kwargs )
+
+ def start( self ):
+ "Overridden to do nothing."
+ return
+
+ def stop( self ):
+ "Overridden to do nothing."
+ return
+
+ def checkListening( self ):
+ "Warn if remote controller is not accessible"
+ listening = self.cmd( "echo A | telnet -e A %s %d" %
+ ( self.ip, self.port ) )
+ if 'Unable' in listening:
+ warn( "Unable to contact the remote controller"
+ " at %s:%d\n" % ( self.ip, self.port ) )
+
+class SDNTopo( Topo ):
+ "SDN Topology"
+
+ def __init__( self, *args, **kwargs ):
+ Topo.__init__( self, *args, **kwargs )
+
+ dist_sw = []
+ aggr_sw = []
+ core_sw = []
+ host = []
+ root = []
+
+ for i in range (4):
+ name_suffix = '%s' % NWID + '0d' + '%02d' % i
+ dpid = '0000' + '0000' + '000' + name_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ dist_sw.append(sw)
+
+ for i in range (4):
+ name_suffix = '%s' % NWID + '0a' + '%02d' % i
+ dpid = '0000' + '0000' + '000' + name_suffix
+ sw = self.addSwitch('sw'+name_suffix, dpid=dpid)
+ aggr_sw.append(sw)
+
+ for i in range (2):
+ name_suffix = '%s' % NWID + '0c' + '%02d' % i
+ dpid = '0000' + '0000' + '000' + name_suffix
+ sw = self.addSwitch('sw' + name_suffix, dpid=dpid)
+ core_sw.append(sw)
+
+ for i in range (8):
+ host.append(self.addHost( 'host%d' % i ))
+
+ for i in range (8):
+ root.append(self.addHost( 'root%d' % i, inNamespace=False ))
+
+ for i in range (8):
+ self.addLink(host[i], dist_sw[int(i/2)])
+
+ for i in range (4):
+ for j in range (int(i/2) * 2, (int(i/2) * 2 + 2)):
+ print 'add link btween dist_sw[%d] -> aggr_sw[%d]' % (i, j)
+ self.addLink(dist_sw[i], aggr_sw[j])
+
+ for i in range (4):
+ for j in range (int(i/4) * 4, int(i/4) * 4 + 2):
+ print 'add link btween aggr_sw[%d] -> core_sw[%d]' % (i, j)
+ self.addLink(aggr_sw[i], core_sw[j])
+
+ for i in range (8):
+ self.addLink(root[i], host[i])
+
+def startsshd( host ):
+ "Start sshd on host"
+ info( '*** Starting sshd\n' )
+ name, intf, ip = host.name, host.defaultIntf(), host.IP()
+ banner = '/tmp/%s.banner' % name
+ host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
+ host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
+ info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
+
+def startsshds ( hosts ):
+ for h in hosts:
+ startsshd( h )
+
+def stopsshd( ):
+ "Stop *all* sshd processes with a custom banner"
+ info( '*** Shutting down stale sshd/Banner processes ',
+ quietRun( "pkill -9 -f Banner" ), '\n' )
+
+def sdnnet(opt):
+ topo = SDNTopo()
+ info( '*** Creating network\n' )
+ net = Mininet( topo=topo, controller=MyController, link=TCLink)
+
+ host = []
+ for i in range (8):
+ host.append(net.get( 'host%d' % i ))
+
+ net.start()
+
+ core_sw = []
+ for i in range (2):
+ name_suffix = '%s' % NWID + '0c' + '%02d' % i
+ net.get('sw' + name_suffix).attach('tap%s0' % NWID)
+
+ for i in range (8):
+ host[i].defaultIntf().setIP('192.168.10.10%d/24' % i)
+
+ root = []
+ for i in range (8):
+ root.append(net.get( 'root%d' % i ))
+
+ for i in range (8):
+ host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
+ root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)
+
+ stopsshd ()
+ startsshds ( host )
+
+ if opt=="cli":
+ CLI(net)
+ stopsshd()
+ net.stop()
+
+if __name__ == '__main__':
+ setLogLevel( 'info' )
+ if len(sys.argv) == 1:
+ sdnnet("cli")
+ elif len(sys.argv) == 2 and sys.argv[1] == "-n":
+ sdnnet("nocli")
+ else:
+ print "%s [-n]" % sys.argv[0]
diff --git a/web/shortest_path.py b/web/shortest_path.py
index 5bea182..381d052 100755
--- a/web/shortest_path.py
+++ b/web/shortest_path.py
@@ -34,6 +34,10 @@
print '%s' % (txt)
# @app.route("/wm/topology/route/<srcdpid>/<srcport>/<destdpid>/<destport>/json")
+#
+# Sample output:
+# {'dstPort': {'port': {'value': 0}, 'dpid': {'value': '00:00:00:00:00:00:00:02'}}, 'srcPort': {'port': {'value': 0}, 'dpid': {'value': '00:00:00:00:00:00:00:01'}}, 'flowEntries': [{'outPort': {'value': 1}, 'flowEntryErrorState': None, 'flowEntryMatch': None, 'flowEntryActions': None, 'inPort': {'value': 0}, 'flowEntryId': None, 'flowEntryUserState': 'FE_USER_UNKNOWN', 'dpid': {'value': '00:00:00:00:00:00:00:01'}, 'flowEntrySwitchState': 'FE_SWITCH_UNKNOWN'}, {'outPort': {'value': 0}, 'flowEntryErrorState': None, 'flowEntryMatch': None, 'flowEntryActions': None, 'inPort': {'value': 9}, 'flowEntryId': None, 'flowEntryUserState': 'FE_USER_UNKNOWN', 'dpid': {'value': '00:00:00:00:00:00:00:02'}, 'flowEntrySwitchState': 'FE_SWITCH_UNKNOWN'}]}
+#
def shortest_path(v1, p1, v2, p2):
try:
command = "curl -s http://%s:%s/wm/topology/route/%s/%s/%s/%s/json" % (ControllerIP, ControllerPort, v1, p1, v2, p2)
@@ -46,10 +50,18 @@
debug("shortest_path %s" % command)
debug("parsed %s" % parsedResult)
- for v in parsedResult:
- dpid = v['switch'];
- port = v['port'];
- print "PathEntry: (%s, %s)" % (dpid, port)
+ srcSwitch = parsedResult['srcPort']['dpid']['value'];
+ srcPort = parsedResult['srcPort']['port']['value'];
+ dstSwitch = parsedResult['dstPort']['dpid']['value'];
+ dstPort = parsedResult['dstPort']['port']['value'];
+
+ print "DataPath: (src = %s/%s dst = %s/%s)" % (srcSwitch, srcPort, dstSwitch, dstPort);
+
+ for f in parsedResult['flowEntries']:
+ inPort = f['inPort']['value'];
+ outPort = f['outPort']['value'];
+ dpid = f['dpid']['value']
+ print "FlowEntry: (%s, %s, %s)" % (inPort, dpid, outPort)
if __name__ == "__main__":