Moved pure ONOS code in net.floodlightcontroller.util to onos package namespace
diff --git a/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java b/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
index 6044598..d7f3e60 100644
--- a/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
+++ b/src/main/java/net/onrc/onos/flow/FlowManagerImpl.java
@@ -18,18 +18,18 @@
import com.tinkerpop.blueprints.Vertex;
import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.util.DataPath;
-import net.floodlightcontroller.util.Dpid;
-import net.floodlightcontroller.util.FlowEntry;
-import net.floodlightcontroller.util.FlowEntryAction;
-import net.floodlightcontroller.util.FlowEntryMatch;
-import net.floodlightcontroller.util.FlowPath;
-import net.floodlightcontroller.util.Port;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.FlowEntryAction;
+import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.LocalTopologyEventListener;
import net.onrc.onos.util.GraphDBConnection.Transaction;
diff --git a/src/main/java/net/onrc/onos/flow/IFlowManager.java b/src/main/java/net/onrc/onos/flow/IFlowManager.java
index a3c2965..4063a7a 100644
--- a/src/main/java/net/onrc/onos/flow/IFlowManager.java
+++ b/src/main/java/net/onrc/onos/flow/IFlowManager.java
@@ -3,9 +3,9 @@
import java.util.Map;
import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.util.FlowEntry;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.FlowPath;
public interface IFlowManager {
/**
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
index f657852..30491a9 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/BgpRoute.java
@@ -23,14 +23,14 @@
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.topology.ITopologyListener;
import net.floodlightcontroller.topology.ITopologyService;
-import net.floodlightcontroller.util.DataPath;
-import net.floodlightcontroller.util.Dpid;
-import net.floodlightcontroller.util.FlowEntry;
-import net.floodlightcontroller.util.IPv4;
import net.floodlightcontroller.util.MACAddress;
-import net.floodlightcontroller.util.Port;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.IPv4;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java b/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java
index eaa3686..4c4728f 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/bgproute/GatewayRouter.java
@@ -1,8 +1,8 @@
package net.onrc.onos.ofcontroller.bgproute;
-import net.floodlightcontroller.util.IPv4;
import net.floodlightcontroller.util.MACAddress;
-import net.floodlightcontroller.util.SwitchPort;
+import net.onrc.onos.ofcontroller.util.IPv4;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
public class GatewayRouter {
private SwitchPort attachmentPoint;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyService.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyService.java
index b67ca95..1992624 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyService.java
@@ -6,11 +6,11 @@
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.routing.Link;
import net.floodlightcontroller.topology.NodePortTuple;
-import net.floodlightcontroller.util.DataPath;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
public interface INetMapTopologyService extends INetMapService {
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
index 02fd920..355ce8e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/FlowManager.java
@@ -25,23 +25,8 @@
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.restserver.IRestApiService;
-import net.floodlightcontroller.util.CallerId;
-import net.floodlightcontroller.util.DataPath;
-import net.floodlightcontroller.util.DataPathEndpoints;
-import net.floodlightcontroller.util.Dpid;
-import net.floodlightcontroller.util.FlowEntry;
-import net.floodlightcontroller.util.FlowEntryAction;
-import net.floodlightcontroller.util.FlowEntryId;
-import net.floodlightcontroller.util.FlowEntryMatch;
-import net.floodlightcontroller.util.FlowEntrySwitchState;
-import net.floodlightcontroller.util.FlowEntryUserState;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
-import net.floodlightcontroller.util.IPv4Net;
import net.floodlightcontroller.util.MACAddress;
import net.floodlightcontroller.util.OFMessageDamper;
-import net.floodlightcontroller.util.Port;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.core.INetMapStorage;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
@@ -49,6 +34,21 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
import net.onrc.onos.ofcontroller.flowcache.web.FlowWebRoutable;
+import net.onrc.onos.ofcontroller.util.CallerId;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.FlowEntryAction;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
+import net.onrc.onos.ofcontroller.util.FlowEntrySwitchState;
+import net.onrc.onos.ofcontroller.util.FlowEntryUserState;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.IPv4Net;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBConnection.Transaction;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/IFlowService.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/IFlowService.java
index bec853f..06566d4 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/IFlowService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/IFlowService.java
@@ -3,11 +3,11 @@
import java.util.ArrayList;
import net.floodlightcontroller.core.module.IFloodlightService;
-import net.floodlightcontroller.util.CallerId;
-import net.floodlightcontroller.util.DataPathEndpoints;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.util.CallerId;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
/**
* @short Interface for providing Flow Service to other modules.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java
index 2557c40..0763b8a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddFlowResource.java
@@ -2,9 +2,9 @@
import java.io.IOException;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.ObjectMapper;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java
index 5a1c36f..59a8972 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/AddShortestPathFlowResource.java
@@ -2,9 +2,9 @@
import java.io.IOException;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.ObjectMapper;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java
index fe19ce0..e51bc9d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/ClearFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java
index f393c0e..fb3d100 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/DeleteFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
index 2c3d81e..c284a9c 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByEndpointsResource.java
@@ -2,12 +2,12 @@
import java.util.ArrayList;
-import net.floodlightcontroller.util.DataPathEndpoints;
-import net.floodlightcontroller.util.Dpid;
-import net.floodlightcontroller.util.FlowPath;
-import net.floodlightcontroller.util.Port;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java
index f55e105..8247422 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsByInstallerIdResource.java
@@ -2,13 +2,13 @@
import java.util.ArrayList;
-import net.floodlightcontroller.util.CallerId;
-import net.floodlightcontroller.util.DataPathEndpoints;
-import net.floodlightcontroller.util.Dpid;
-import net.floodlightcontroller.util.FlowPath;
-import net.floodlightcontroller.util.Port;
-import net.floodlightcontroller.util.SwitchPort;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.CallerId;
+import net.onrc.onos.ofcontroller.util.DataPathEndpoints;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowPath;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java
index 1f9176f..5ffbefa 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetAllFlowsResource.java
@@ -2,8 +2,8 @@
import java.util.ArrayList;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java
index fbfc169..2f0f712 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetFlowByIdResource.java
@@ -1,8 +1,8 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java
index ed0aea8..54c75f2 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/GetSummaryFlowsResource.java
@@ -2,10 +2,10 @@
import java.util.ArrayList;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java
index 58dd3f4..d0c013e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementClearAllPathsFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
index 83ac152..2d2fbf6 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetInstallPathsTimeNsecFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java
index c01e624..981c12c 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementGetPerFlowInstallTimeFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java
index e0ecb18..911de89 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementInstallPathsFlowResource.java
@@ -1,7 +1,7 @@
package net.onrc.onos.ofcontroller.flowcache.web;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
import org.openflow.util.HexString;
import org.restlet.resource.Get;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java
index 42b1d7d..5eb8af0 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowcache/web/MeasurementStorePathFlowResource.java
@@ -2,9 +2,9 @@
import java.io.IOException;
-import net.floodlightcontroller.util.FlowId;
-import net.floodlightcontroller.util.FlowPath;
import net.onrc.onos.ofcontroller.flowcache.IFlowService;
+import net.onrc.onos.ofcontroller.util.FlowId;
+import net.onrc.onos.ofcontroller.util.FlowPath;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.ObjectMapper;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java b/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
index 92b6040..f20f7ca 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/routing/TopoRouteService.java
@@ -15,14 +15,14 @@
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
-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 net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoRouteService;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+import net.onrc.onos.ofcontroller.util.DataPath;
+import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.Port;
+import net.onrc.onos.ofcontroller.util.SwitchPort;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBConnection.Transaction;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/CallerId.java b/src/main/java/net/onrc/onos/ofcontroller/util/CallerId.java
new file mode 100644
index 0000000..0607533
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/CallerId.java
@@ -0,0 +1,52 @@
+package net.onrc.onos.ofcontroller.util;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing a Caller ID for an ONOS component.
+ */
+public class CallerId {
+ private String value;
+
+ /**
+ * Default constructor.
+ */
+ public CallerId() {}
+
+ /**
+ * Constructor from a string value.
+ *
+ * @param value the value to use.
+ */
+ public CallerId(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the value of the Caller ID.
+ *
+ * @return the value of the Caller ID.
+ */
+ @JsonProperty("value")
+ public String value() { return value; }
+
+ /**
+ * Set the value of the Caller ID.
+ *
+ * @param value the value to set.
+ */
+ @JsonProperty("value")
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the Caller ID value to a string.
+ *
+ * @return the Caller ID value to a string.
+ */
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/DataPath.java b/src/main/java/net/onrc/onos/ofcontroller/util/DataPath.java
new file mode 100644
index 0000000..f02552b
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/DataPath.java
@@ -0,0 +1,129 @@
+package net.onrc.onos.ofcontroller.util;
+
+import java.util.ArrayList;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Data Path.
+ */
+public class DataPath {
+ private SwitchPort srcPort; // The source port
+ private SwitchPort dstPort; // The destination port
+ private ArrayList<FlowEntry> flowEntries; // The Flow Entries
+
+ /**
+ * Default constructor.
+ */
+ public DataPath() {
+ srcPort = new SwitchPort();
+ dstPort = new SwitchPort();
+ flowEntries = new ArrayList<FlowEntry>();
+ }
+
+ /**
+ * Get the data path source port.
+ *
+ * @return the data path source port.
+ */
+ @JsonProperty("srcPort")
+ public SwitchPort srcPort() { return srcPort; }
+
+ /**
+ * Set the data path source port.
+ *
+ * @param srcPort the data path source port to set.
+ */
+ @JsonProperty("srcPort")
+ public void setSrcPort(SwitchPort srcPort) {
+ this.srcPort = srcPort;
+ }
+
+ /**
+ * Get the data path destination port.
+ *
+ * @return the data path destination port.
+ */
+ @JsonProperty("dstPort")
+ public SwitchPort dstPort() { return dstPort; }
+
+ /**
+ * Set the data path destination port.
+ *
+ * @param dstPort the data path destination port to set.
+ */
+ @JsonProperty("dstPort")
+ public void setDstPort(SwitchPort dstPort) {
+ this.dstPort = dstPort;
+ }
+
+ /**
+ * Get the data path flow entries.
+ *
+ * @return the data path flow entries.
+ */
+ @JsonProperty("flowEntries")
+ public ArrayList<FlowEntry> flowEntries() { return flowEntries; }
+
+ /**
+ * Set the data path flow entries.
+ *
+ * @param flowEntries the data path flow entries to set.
+ */
+ @JsonProperty("flowEntries")
+ public void setFlowEntries(ArrayList<FlowEntry> flowEntries) {
+ this.flowEntries = flowEntries;
+ }
+
+ /**
+ * Get a string with the summary of the shortest-path data path
+ * computation.
+ *
+ * NOTE: This method assumes the DataPath was created by
+ * using FlowManager::getShortestPath() so the inPort and outPort
+ * of the Flow Entries are set.
+ * NOTE: This method is a temporary solution and will be removed
+ * in the future.
+ *
+ * @return a string with the summary of the shortest-path
+ * data path computation if valid, otherwise the string "X".
+ * If the shortest-path was valid, The string has the following form:
+ * inPort/dpid/outPort;inPort/dpid/outPort;...
+ */
+ public String dataPathSummary() {
+ String resultStr = new String();
+ if (this.flowEntries != null) {
+ for (FlowEntry flowEntry : this.flowEntries) {
+ // The data path summary string
+ resultStr = resultStr +
+ flowEntry.inPort().toString() + "/"
+ + flowEntry.dpid().toString() + "/" +
+ flowEntry.outPort().toString() + ";";
+ }
+ }
+ if (resultStr.isEmpty())
+ resultStr = "X"; // Invalid shortest-path
+ return resultStr;
+ }
+
+ /**
+ * Convert the data path to a string.
+ *
+ * The string has the following form:
+ * [src=01:01:01:01:01:01:01:01/1111 flowEntry=<entry1> flowEntry=<entry2> flowEntry=<entry3> dst=02:02:02:02:02:02:02:02/2222]
+ *
+ * @return the data path as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[src=" + this.srcPort.toString();
+
+ for (FlowEntry fe : flowEntries) {
+ ret += " flowEntry=" + fe.toString();
+ }
+ ret += " dst=" + this.dstPort.toString() + "]";
+
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/DataPathEndpoints.java b/src/main/java/net/onrc/onos/ofcontroller/util/DataPathEndpoints.java
new file mode 100644
index 0000000..9cdd4fb
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/DataPathEndpoints.java
@@ -0,0 +1,80 @@
+package net.onrc.onos.ofcontroller.util;
+
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Data Path Endpoints.
+ */
+public class DataPathEndpoints {
+ private SwitchPort srcPort; // The source port
+ private SwitchPort dstPort; // The destination port
+
+ /**
+ * Default constructor.
+ */
+ public DataPathEndpoints() {
+ }
+
+ /**
+ * Constructor for given source and destination ports.
+ *
+ * @param srcPort the source port to use.
+ * @param dstPort the destination port to use.
+ */
+ public DataPathEndpoints(SwitchPort srcPort, SwitchPort dstPort) {
+ this.srcPort = srcPort;
+ this.dstPort = dstPort;
+ }
+
+ /**
+ * Get the data path source port.
+ *
+ * @return the data path source port.
+ */
+ @JsonProperty("srcPort")
+ public SwitchPort srcPort() { return srcPort; }
+
+ /**
+ * Set the data path source port.
+ *
+ * @param srcPort the data path source port to set.
+ */
+ @JsonProperty("srcPort")
+ public void setSrcPort(SwitchPort srcPort) {
+ this.srcPort = srcPort;
+ }
+
+ /**
+ * Get the data path destination port.
+ *
+ * @return the data path destination port.
+ */
+ @JsonProperty("dstPort")
+ public SwitchPort dstPort() { return dstPort; }
+
+ /**
+ * Set the data path destination port.
+ *
+ * @param dstPort the data path destination port to set.
+ */
+ @JsonProperty("dstPort")
+ public void setDstPort(SwitchPort dstPort) {
+ this.dstPort = dstPort;
+ }
+
+ /**
+ * Convert the data path endpoints to a string.
+ *
+ * The string has the following form:
+ * [src=01:01:01:01:01:01:01:01/1111 dst=02:02:02:02:02:02:02:02/2222]
+ *
+ * @return the data path endpoints as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[src=" + this.srcPort.toString() +
+ " dst=" + this.dstPort.toString() + "]";
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java b/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java
new file mode 100644
index 0000000..4e46d84
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/Dpid.java
@@ -0,0 +1,71 @@
+package net.onrc.onos.ofcontroller.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;
+
+ private long value;
+
+ /**
+ * Default constructor.
+ */
+ public Dpid() {
+ this.value = Dpid.UNKNOWN;
+ }
+
+ /**
+ * Constructor from a long value.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(long value) {
+ this.value = value;
+ }
+
+ /**
+ * 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.
+ */
+ public long value() { return value; }
+
+ /**
+ * Set the value of the DPID.
+ *
+ * @param value the value to set.
+ */
+ public void setValue(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the DPID value to a ':' separated hexadecimal string.
+ *
+ * @return the DPID value as a ':' separated hexadecimal string.
+ */
+ @Override
+ public String toString() {
+ return HexString.toHexString(this.value);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntry.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntry.java
new file mode 100644
index 0000000..ac32d0b
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntry.java
@@ -0,0 +1,354 @@
+package net.onrc.onos.ofcontroller.util;
+
+import java.util.ArrayList;
+
+
+import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.ofcontroller.util.FlowEntryAction;
+import net.onrc.onos.ofcontroller.util.FlowEntryErrorState;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
+import net.onrc.onos.ofcontroller.util.FlowEntrySwitchState;
+import net.onrc.onos.ofcontroller.util.FlowEntryUserState;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Flow Entry.
+ *
+ * NOTE: The specification is incomplete. E.g., the entry needs to
+ * support multiple in-ports and multiple out-ports.
+ */
+public class FlowEntry {
+ private FlowId flowId; // FlowID of flowEntry
+ private FlowEntryId flowEntryId; // The Flow Entry ID
+ private FlowEntryMatch flowEntryMatch; // The Flow Entry Match
+ private ArrayList<FlowEntryAction> flowEntryActions; // The Flow Entry Actions
+ private Dpid dpid; // The Switch DPID
+ private Port inPort; // The Switch incoming port. Used only
+ // when the entry is used to return
+ // Shortest Path computation.
+ private Port outPort; // The Switch outgoing port. Used only
+ // when the entry is used to return
+ // Shortest Path computation.
+ private FlowEntryUserState flowEntryUserState; // The Flow Entry User state
+ private FlowEntrySwitchState flowEntrySwitchState; // The Flow Entry Switch state
+ // The Flow Entry Error state (if FlowEntrySwitchState is FE_SWITCH_FAILED)
+ private FlowEntryErrorState flowEntryErrorState;
+
+ /**
+ * Default constructor.
+ */
+ public FlowEntry() {
+ // TODO: Test code
+ /*
+ MACAddress mac = MACAddress.valueOf("01:02:03:04:05:06");
+ IPv4 ipv4 = new IPv4("1.2.3.4");
+ IPv4Net ipv4net = new IPv4Net("5.6.7.0/24");
+
+ flowEntryMatch = new FlowEntryMatch();
+ flowEntryMatch.enableInPort(new Port((short)10));
+ flowEntryMatch.enableSrcMac(mac);
+ flowEntryMatch.enableDstMac(mac);
+ flowEntryMatch.enableVlanId((short)20);
+ flowEntryMatch.enableVlanPriority((byte)30);
+ flowEntryMatch.enableEthernetFrameType((short)40);
+ flowEntryMatch.enableIpToS((byte)50);
+ flowEntryMatch.enableIpProto((byte)60);
+ flowEntryMatch.enableSrcIPv4Net(ipv4net);
+ flowEntryMatch.enableDstIPv4Net(ipv4net);
+ flowEntryMatch.enableSrcTcpUdpPort((short)70);
+ flowEntryMatch.enableDstTcpUdpPort((short)80);
+
+ FlowEntryAction action = null;
+ ArrayList<FlowEntryAction> actions = new ArrayList<FlowEntryAction>();
+
+ action = new FlowEntryAction();
+ action.setActionOutput(new Port((short)12));
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionOutputToController((short)13);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetVlanId((short)14);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetVlanPriority((byte)15);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionStripVlan(true);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetEthernetSrcAddr(mac);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetEthernetDstAddr(mac);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetIPv4SrcAddr(ipv4);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetIPv4DstAddr(ipv4);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetIpToS((byte)16);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetTcpUdpSrcPort((short)17);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionSetTcpUdpDstPort((short)18);
+ actions.add(action);
+
+ action = new FlowEntryAction();
+ action.setActionEnqueue(new Port((short)19), 20);
+ actions.add(action);
+
+ setFlowEntryActions(actions);
+ */
+
+
+ flowEntryUserState = FlowEntryUserState.FE_USER_UNKNOWN;
+ flowEntrySwitchState = FlowEntrySwitchState.FE_SWITCH_UNKNOWN;
+ }
+
+ /**
+ * Get the Flow ID.
+ * @return the Flow ID.
+ */
+ @JsonIgnore
+ public FlowId getFlowId() { return flowId; }
+
+ /**
+ * Set the Flow ID.
+ *
+ * @param flowId the Flow ID to set.
+ */
+ public void setFlowId(FlowId flowId) {
+ this.flowId = flowId;
+ }
+
+ /**
+ * Get the Flow Entry ID.
+ *
+ * @return the Flow Entry ID.
+ */
+ @JsonProperty("flowEntryId")
+ public FlowEntryId flowEntryId() { return flowEntryId; }
+
+ /**
+ * Set the Flow Entry ID.
+ *
+ * @param flowEntryId the Flow Entry ID to set.
+ */
+ @JsonProperty("flowEntryId")
+ public void setFlowEntryId(FlowEntryId flowEntryId) {
+ this.flowEntryId = flowEntryId;
+ }
+
+ /**
+ * Get the Flow Entry Match.
+ *
+ * @return the Flow Entry Match.
+ */
+ @JsonProperty("flowEntryMatch")
+ public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; }
+
+ /**
+ * Set the Flow Entry Match.
+ *
+ * @param flowEntryMatch the Flow Entry Match to set.
+ */
+ @JsonProperty("flowEntryMatch")
+ public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) {
+ this.flowEntryMatch = flowEntryMatch;
+ }
+
+ /**
+ * Get the Flow Entry Actions.
+ *
+ * @return the Flow Entry Actions.
+ */
+ @JsonProperty("flowEntryActions")
+ public ArrayList<FlowEntryAction> flowEntryActions() {
+ return flowEntryActions;
+ }
+
+ /**
+ * Set the Flow Entry Actions.
+ *
+ * @param flowEntryActions the Flow Entry Actions to set.
+ */
+ @JsonProperty("flowEntryActions")
+ public void setFlowEntryActions(ArrayList<FlowEntryAction> flowEntryActions) {
+ this.flowEntryActions = flowEntryActions;
+ }
+
+ /**
+ * Get the Switch DPID.
+ *
+ * @return the Switch DPID.
+ */
+ @JsonProperty("dpid")
+ public Dpid dpid() { return dpid; }
+
+ /**
+ * Set the Switch DPID.
+ *
+ * @param dpid the Switch DPID to set.
+ */
+ @JsonProperty("dpid")
+ public void setDpid(Dpid dpid) {
+ this.dpid = dpid;
+ }
+
+ /**
+ * Get the Switch incoming port.
+ *
+ * Used only when the entry is used to return Shortest Path computation.
+ *
+ * @return the Switch incoming port.
+ */
+ @JsonProperty("inPort")
+ public Port inPort() { return inPort; }
+
+ /**
+ * Set the Switch incoming port.
+ *
+ * Used only when the entry is used to return Shortest Path computation.
+ *
+ * @param inPort the Switch incoming port to set.
+ */
+ @JsonProperty("inPort")
+ public void setInPort(Port inPort) {
+ this.inPort = inPort;
+ }
+
+ /**
+ * Get the Switch outgoing port.
+ *
+ * Used only when the entry is used to return Shortest Path computation.
+ *
+ * @return the Switch outgoing port.
+ */
+ @JsonProperty("outPort")
+ public Port outPort() { return outPort; }
+
+ /**
+ * Set the Switch outgoing port.
+ *
+ * Used only when the entry is used to return Shortest Path computation.
+ *
+ * @param outPort the Switch outgoing port to set.
+ */
+ @JsonProperty("outPort")
+ public void setOutPort(Port outPort) {
+ this.outPort = outPort;
+ }
+
+ /**
+ * Get the Flow Entry User state.
+ *
+ * @return the Flow Entry User state.
+ */
+ @JsonProperty("flowEntryUserState")
+ public FlowEntryUserState flowEntryUserState() {
+ return flowEntryUserState;
+ }
+
+ /**
+ * Set the Flow Entry User state.
+ *
+ * @param flowEntryUserState the Flow Entry User state to set.
+ */
+ @JsonProperty("flowEntryUserState")
+ public void setFlowEntryUserState(FlowEntryUserState flowEntryUserState) {
+ this.flowEntryUserState = flowEntryUserState;
+ }
+
+ /**
+ * Get the Flow Entry Switch state.
+ *
+ * The Flow Entry Error state is used if FlowEntrySwitchState is
+ * FE_SWITCH_FAILED.
+ *
+ * @return the Flow Entry Switch state.
+ */
+ @JsonProperty("flowEntrySwitchState")
+ public FlowEntrySwitchState flowEntrySwitchState() {
+ return flowEntrySwitchState;
+ }
+
+ /**
+ * Set the Flow Entry Switch state.
+ *
+ * The Flow Entry Error state is used if FlowEntrySwitchState is
+ * FE_SWITCH_FAILED.
+ *
+ * @param flowEntrySwitchState the Flow Entry Switch state to set.
+ */
+ @JsonProperty("flowEntrySwitchState")
+ public void setFlowEntrySwitchState(FlowEntrySwitchState flowEntrySwitchState) {
+ this.flowEntrySwitchState = flowEntrySwitchState;
+ }
+
+ /**
+ * Get the Flow Entry Error state.
+ *
+ * @return the Flow Entry Error state.
+ */
+ @JsonProperty("flowEntryErrorState")
+ public FlowEntryErrorState flowEntryErrorState() {
+ return flowEntryErrorState;
+ }
+
+ /**
+ * Set the Flow Entry Error state.
+ *
+ * @param flowEntryErrorState the Flow Entry Error state to set.
+ */
+ @JsonProperty("flowEntryErrorState")
+ public void setFlowEntryErrorState(FlowEntryErrorState flowEntryErrorState) {
+ this.flowEntryErrorState = flowEntryErrorState;
+ }
+
+ /**
+ * Convert the flow entry to a string.
+ *
+ * The string has the following form:
+ * [flowEntryId=XXX flowEntryMatch=XXX flowEntryAction=XXX
+ * flowEntryAction=XXX flowEntryAction=XXX dpid=XXX
+ * inPort=XXX outPort=XXX flowEntryUserState=XXX flowEntrySwitchState=XXX
+ * flowEntryErrorState=XXX]
+ * @return the flow entry as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[flowEntryId=" + this.flowEntryId.toString();
+ ret += " flowEntryMatch=" + this.flowEntryMatch.toString();
+ for (FlowEntryAction fa : flowEntryActions) {
+ ret += " flowEntryAction=" + fa.toString();
+ }
+ ret += " dpid=" + this.dpid.toString();
+ ret += " inPort=" + this.inPort.toString();
+ ret += " outPort=" + this.outPort.toString();
+ ret += " flowEntryUserState=" + this.flowEntryUserState;
+ ret += " flowEntrySwitchState=" + this.flowEntrySwitchState;
+ ret += " flowEntryErrorState=" + this.flowEntryErrorState.toString();
+ ret += "]";
+
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryAction.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryAction.java
new file mode 100644
index 0000000..858272c
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryAction.java
@@ -0,0 +1,1014 @@
+package net.onrc.onos.ofcontroller.util;
+
+import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.ofcontroller.util.Port.PortValues;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing a single Flow Entry action.
+ *
+ * A set of Flow Entry actions need to be applied to each packet.
+ */
+public class FlowEntryAction {
+ /**
+ * Special action values.
+ *
+ * Those values are taken as-is from the OpenFlow-v1.0.0 specification
+ * (pp 21-22).
+ */
+ public enum ActionValues {
+ ACTION_OUTPUT ((short)0x0), // Output to switch port
+ ACTION_SET_VLAN_VID ((short)0x1), // Set the 802.1q VLAN id
+ ACTION_SET_VLAN_PCP ((short)0x2), // Set the 802.1q priority
+ ACTION_STRIP_VLAN ((short)0x3), // Strip the 802.1q header
+ ACTION_SET_DL_SRC ((short)0x4), // Ethernet source address
+ ACTION_SET_DL_DST ((short)0x5), // Ethernet destination address
+ ACTION_SET_NW_SRC ((short)0x6), // IP source address
+ ACTION_SET_NW_DST ((short)0x7), // IP destination address
+ ACTION_SET_NW_TOS ((short)0x8), // IP ToS (DSCP field, 6 bits)
+ ACTION_SET_TP_SRC ((short)0x9), // TCP/UDP source port
+ ACTION_SET_TP_DST ((short)0xa), // TCP/UDP destination port
+ ACTION_ENQUEUE ((short)0xb), // Output to queue on port
+ ACTION_VENDOR ((short)0xffff); // Vendor-specific
+
+ private final short value; // The value
+
+ /**
+ * Constructor for a given value.
+ *
+ * @param value the value to use for the initialization.
+ */
+ private ActionValues(short value) {
+ this.value = value;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_OUTPUT: Output to switch port.
+ */
+ public class ActionOutput {
+ private Port port; // Output port
+ private short maxLen; // Max. length (in bytes) to send to controller
+ // if the port is set to PORT_CONTROLLER
+
+ /**
+ * Default constructor.
+ */
+ public ActionOutput() {
+ this.port = null;
+ this.maxLen = 0;
+ }
+
+
+ /**
+ * Constructor for a given output port and maximum length.
+ *
+ * @param port the output port to set.
+ * @param maxLen the maximum length (in bytes) to send to controller
+ * if the port is set to PORT_CONTROLLER.
+ */
+ public ActionOutput(Port port, short maxLen) {
+ this.port = port;
+ this.maxLen = maxLen;
+ }
+
+ /**
+ * Constructor for a given output port.
+ *
+ * @param port the output port to set.
+ */
+ public ActionOutput(Port port) {
+ this.port = port;
+ this.maxLen = 0;
+ }
+
+ /**
+ * Get the output port.
+ *
+ * @return the output port.
+ */
+ @JsonProperty("port")
+ public Port port() {
+ return this.port;
+ }
+
+ /**
+ * Get the maximum length (in bytes) to send to controller if the
+ * port is set to PORT_CONTROLLER.
+ *
+ * @return the maximum length (in bytes) to send to controller if the
+ * port is set to PORT_CONTROLLER.
+ */
+ @JsonProperty("maxLen")
+ public short maxLen() {
+ return this.maxLen;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [port=XXX maxLen=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "port=" + port.toString();
+ ret += " maxLen=" + maxLen;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_VLAN_VID: Set the 802.1q VLAN id
+ */
+ public class ActionSetVlanId {
+ private short vlanId; // The VLAN ID to set
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetVlanId() {
+ this.vlanId = 0;
+ }
+
+ /**
+ * Constructor for a given VLAN ID.
+ *
+ * @param vlanId the VLAN ID to set.
+ */
+ public ActionSetVlanId(short vlanId) {
+ this.vlanId = vlanId;
+ }
+
+ /**
+ * Get the VLAN ID.
+ *
+ * @return the VLAN ID.
+ */
+ @JsonProperty("vlanId")
+ public short vlanId() {
+ return this.vlanId;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [vlanId=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "vlanId=" + this.vlanId;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_VLAN_PCP: Set the 802.1q priority
+ */
+ public class ActionSetVlanPriority {
+ private byte vlanPriority; // The VLAN priority to set
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetVlanPriority() {
+ this.vlanPriority = 0;
+ }
+
+ /**
+ * Constructor for a given VLAN priority.
+ *
+ * @param vlanPriority the VLAN priority to set.
+ */
+ public ActionSetVlanPriority(byte vlanPriority) {
+ this.vlanPriority = vlanPriority;
+ }
+
+ /**
+ * Get the VLAN priority.
+ *
+ * @return the VLAN priority.
+ */
+ @JsonProperty("vlanPriority")
+ public byte vlanPriority() {
+ return this.vlanPriority;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [vlanPriority=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "vlanPriority=" + this.vlanPriority;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_STRIP_VLAN: Strip the 802.1q header
+ */
+ public class ActionStripVlan {
+ private boolean stripVlan; // If true, strip the VLAN header
+
+ /**
+ * Default constructor.
+ */
+ public ActionStripVlan() {
+ this.stripVlan = false;
+ }
+
+ /**
+ * Constructor for a given boolean flag.
+ *
+ * @param stripVlan if true, strip the VLAN header.
+ */
+ public ActionStripVlan(boolean stripVlan) {
+ this.stripVlan = stripVlan;
+ }
+
+ /**
+ * Get the boolean flag whether the VLAN header should be stripped.
+ *
+ * @return the boolean flag whether the VLAN header should be stripped.
+ */
+ @JsonProperty("stripVlan")
+ public boolean stripVlan() {
+ return this.stripVlan;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [stripVlan=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "stripVlan=" + this.stripVlan;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_DL_SRC and ACTION_SET_DL_DST:
+ * Set the Ethernet source/destination address.
+ */
+ public class ActionSetEthernetAddr {
+ private MACAddress addr; // The MAC address to set
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetEthernetAddr() {
+ this.addr = null;
+ }
+
+ /**
+ * Constructor for a given MAC address.
+ *
+ * @param addr the MAC address to set.
+ */
+ public ActionSetEthernetAddr(MACAddress addr) {
+ this.addr = addr;
+ }
+
+ /**
+ * Get the MAC address.
+ *
+ * @return the MAC address.
+ */
+ @JsonProperty("addr")
+ public MACAddress addr() {
+ return this.addr;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [addr=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "addr=" + addr.toString();
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_NW_SRC and ACTION_SET_NW_DST:
+ * Set the IPv4 source/destination address.
+ */
+ public class ActionSetIPv4Addr {
+ private IPv4 addr; // The IPv4 address to set
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetIPv4Addr() {
+ this.addr = null;
+ }
+
+ /**
+ * Constructor for a given IPv4 address.
+ *
+ * @param addr the IPv4 address to set.
+ */
+ public ActionSetIPv4Addr(IPv4 addr) {
+ this.addr = addr;
+ }
+
+ /**
+ * Get the IPv4 address.
+ *
+ * @return the IPv4 address.
+ */
+ @JsonProperty("addr")
+ public IPv4 addr() {
+ return this.addr;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [addr=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "addr=" + addr.toString();
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_NW_TOS:
+ * Set the IP ToS (DSCP field, 6 bits).
+ */
+ public class ActionSetIpToS {
+ private byte ipToS; // The IP ToS to set DSCP field, 6 bits)
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetIpToS() {
+ this.ipToS = 0;
+ }
+
+ /**
+ * Constructor for a given IP ToS (DSCP field, 6 bits).
+ *
+ * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
+ */
+ public ActionSetIpToS(byte ipToS) {
+ this.ipToS = ipToS;
+ }
+
+ /**
+ * Get the IP ToS (DSCP field, 6 bits).
+ *
+ * @return the IP ToS (DSCP field, 6 bits).
+ */
+ @JsonProperty("ipToS")
+ public byte ipToS() {
+ return this.ipToS;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [ipToS=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "ipToS=" + ipToS;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_SET_TP_SRC and ACTION_SET_TP_DST:
+ * Set the TCP/UDP source/destination port.
+ */
+ public class ActionSetTcpUdpPort {
+ private short port; // The TCP/UDP port to set
+
+ /**
+ * Default constructor.
+ */
+ public ActionSetTcpUdpPort() {
+ this.port = 0;
+ }
+
+ /**
+ * Constructor for a given TCP/UDP port.
+ *
+ * @param port the TCP/UDP port to set.
+ */
+ public ActionSetTcpUdpPort(short port) {
+ this.port = port;
+ }
+
+ /**
+ * Get the TCP/UDP port.
+ *
+ * @return the TCP/UDP port.
+ */
+ @JsonProperty("port")
+ public short port() {
+ return this.port;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [port=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "port=" + port;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ /**
+ * Action structure for ACTION_ENQUEUE: Output to queue on port.
+ */
+ public class ActionEnqueue {
+ private Port port; // Port that queue belongs. Should
+ // refer to a valid physical port
+ // (i.e. < PORT_MAX) or PORT_IN_PORT
+ private int queueId; // Where to enqueue the packets
+
+ /**
+ * Default constructor.
+ */
+ public ActionEnqueue() {
+ this.port = null;
+ this.queueId = 0;
+ }
+
+ /**
+ * Constructor for a given port and queue ID.
+ *
+ * @param port the port to set.
+ * @param queueId the queue ID on the port.
+ */
+ public ActionEnqueue(Port port, int queueId) {
+ this.port = port;
+ this.queueId = queueId;
+ }
+
+ /**
+ * Get the port.
+ *
+ * @return the port.
+ */
+ @JsonProperty("port")
+ public Port port() {
+ return this.port;
+ }
+
+ /**
+ * Get the queue ID.
+ *
+ * @return the queue ID.
+ */
+ @JsonProperty("queueId")
+ public int queueId() {
+ return this.queueId;
+ }
+
+ /**
+ * Convert the action to a string.
+ *
+ * The string has the following form:
+ * [port=XXX queueId=XXX]
+ *
+ * @return the action as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "port=" + port.toString();
+ ret += " queueId=" + queueId;
+ ret += "]";
+
+ return ret;
+ }
+ }
+
+ private ActionValues actionType; // The action type
+
+ //
+ // The actions.
+ // NOTE: Only one action should be set.
+ //
+ private ActionOutput actionOutput;
+ private ActionSetVlanId actionSetVlanId;
+ private ActionSetVlanPriority actionSetVlanPriority;
+ private ActionStripVlan actionStripVlan;
+ private ActionSetEthernetAddr actionSetEthernetSrcAddr;
+ private ActionSetEthernetAddr actionSetEthernetDstAddr;
+ private ActionSetIPv4Addr actionSetIPv4SrcAddr;
+ private ActionSetIPv4Addr actionSetIPv4DstAddr;
+ private ActionSetIpToS actionSetIpToS;
+ private ActionSetTcpUdpPort actionSetTcpUdpSrcPort;
+ private ActionSetTcpUdpPort actionSetTcpUdpDstPort;
+ private ActionEnqueue actionEnqueue;
+
+ /**
+ * Default constructor.
+ */
+ public FlowEntryAction() {
+ actionType = ActionValues.ACTION_VENDOR; // XXX: Initial value
+ }
+
+ /**
+ * Get the action type.
+ *
+ * @return the action type.
+ */
+ @JsonProperty("actionType")
+ public ActionValues actionType() { return actionType; }
+
+ /**
+ * Get the output action.
+ *
+ * @return the output action.
+ */
+ @JsonProperty("actionOutput")
+ public ActionOutput actionOutput() { return actionOutput; }
+
+ /**
+ * Set the output action on a port.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionOutput")
+ public void setActionOutput(ActionOutput action) {
+ actionOutput = action;
+ actionType = ActionValues.ACTION_OUTPUT;
+ }
+
+ /**
+ * Set the output action on a port.
+ *
+ * @param port the output port to set.
+ */
+ public void setActionOutput(Port port) {
+ actionOutput = new ActionOutput(port);
+ actionType = ActionValues.ACTION_OUTPUT;
+ }
+
+ /**
+ * Set the output action to controller.
+ *
+ * @param maxLen the maximum length (in bytes) to send to controller.
+ */
+ public void setActionOutputToController(short maxLen) {
+ Port port = new Port(Port.PortValues.PORT_CONTROLLER);
+ actionOutput = new ActionOutput(port, maxLen);
+ actionType = ActionValues.ACTION_OUTPUT;
+ }
+
+ /**
+ * Get the action to set the VLAN ID.
+ *
+ * @return the action to set the VLAN ID.
+ */
+ @JsonProperty("actionSetVlanId")
+ public ActionSetVlanId actionSetVlanId() { return actionSetVlanId; }
+
+ /**
+ * Set the action to set the VLAN ID.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetVlanId")
+ public void setActionSetVlanId(ActionSetVlanId action) {
+ actionSetVlanId = action;
+ actionType = ActionValues.ACTION_SET_VLAN_VID;
+ }
+
+ /**
+ * Set the action to set the VLAN ID.
+ *
+ * @param vlanId the VLAN ID to set.
+ */
+ public void setActionSetVlanId(short vlanId) {
+ actionSetVlanId = new ActionSetVlanId(vlanId);
+ actionType = ActionValues.ACTION_SET_VLAN_VID;
+ }
+
+ /**
+ * Get the action to set the VLAN priority.
+ *
+ * @return the action to set the VLAN priority.
+ */
+ @JsonProperty("actionSetVlanPriority")
+ public ActionSetVlanPriority actionSetVlanPriority() {
+ return actionSetVlanPriority;
+ }
+
+ /**
+ * Set the action to set the VLAN priority.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetVlanPriority")
+ public void setActionSetVlanPriority(ActionSetVlanPriority action) {
+ actionSetVlanPriority = action;
+ actionType = ActionValues.ACTION_SET_VLAN_PCP;
+ }
+
+ /**
+ * Set the action to set the VLAN priority.
+ *
+ * @param vlanPriority the VLAN priority to set.
+ */
+ public void setActionSetVlanPriority(byte vlanPriority) {
+ actionSetVlanPriority = new ActionSetVlanPriority(vlanPriority);
+ actionType = ActionValues.ACTION_SET_VLAN_PCP;
+ }
+
+ /**
+ * Get the action to strip the VLAN header.
+ *
+ * @return the action to strip the VLAN header.
+ */
+ @JsonProperty("actionStripVlan")
+ public ActionStripVlan actionStripVlan() {
+ return actionStripVlan;
+ }
+
+ /**
+ * Set the action to strip the VLAN header.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionStripVlan")
+ public void setActionStripVlan(ActionStripVlan action) {
+ actionStripVlan = action;
+ actionType = ActionValues.ACTION_STRIP_VLAN;
+ }
+
+ /**
+ * Set the action to strip the VLAN header.
+ *
+ * @param stripVlan if true, strip the VLAN header.
+ */
+ public void setActionStripVlan(boolean stripVlan) {
+ actionStripVlan = new ActionStripVlan(stripVlan);
+ actionType = ActionValues.ACTION_STRIP_VLAN;
+ }
+
+ /**
+ * Get the action to set the Ethernet source address.
+ *
+ * @return the action to set the Ethernet source address.
+ */
+ @JsonProperty("actionSetEthernetSrcAddr")
+ public ActionSetEthernetAddr actionSetEthernetSrcAddr() {
+ return actionSetEthernetSrcAddr;
+ }
+
+ /**
+ * Set the action to set the Ethernet source address.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetEthernetSrcAddr")
+ public void setActionSetEthernetSrcAddr(ActionSetEthernetAddr action) {
+ actionSetEthernetSrcAddr = action;
+ actionType = ActionValues.ACTION_SET_DL_SRC;
+ }
+
+ /**
+ * Set the action to set the Ethernet source address.
+ *
+ * @param addr the MAC address to set as the Ethernet source address.
+ */
+ public void setActionSetEthernetSrcAddr(MACAddress addr) {
+ actionSetEthernetSrcAddr = new ActionSetEthernetAddr(addr);
+ actionType = ActionValues.ACTION_SET_DL_SRC;
+ }
+
+ /**
+ * Get the action to set the Ethernet destination address.
+ *
+ * @return the action to set the Ethernet destination address.
+ */
+ @JsonProperty("actionSetEthernetDstAddr")
+ public ActionSetEthernetAddr actionSetEthernetDstAddr() {
+ return actionSetEthernetDstAddr;
+ }
+
+ /**
+ * Set the action to set the Ethernet destination address.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetEthernetDstAddr")
+ public void setActionSetEthernetDstAddr(ActionSetEthernetAddr action) {
+ actionSetEthernetDstAddr = action;
+ actionType = ActionValues.ACTION_SET_DL_DST;
+ }
+
+ /**
+ * Set the action to set the Ethernet destination address.
+ *
+ * @param addr the MAC address to set as the Ethernet destination address.
+ */
+ public void setActionSetEthernetDstAddr(MACAddress addr) {
+ actionSetEthernetDstAddr = new ActionSetEthernetAddr(addr);
+ actionType = ActionValues.ACTION_SET_DL_DST;
+ }
+
+ /**
+ * Get the action to set the IPv4 source address.
+ *
+ * @return the action to set the IPv4 source address.
+ */
+ @JsonProperty("actionSetIPv4SrcAddr")
+ public ActionSetIPv4Addr actionSetIPv4SrcAddr() {
+ return actionSetIPv4SrcAddr;
+ }
+
+ /**
+ * Set the action to set the IPv4 source address.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetIPv4SrcAddr")
+ public void setActionSetIPv4SrcAddr(ActionSetIPv4Addr action) {
+ actionSetIPv4SrcAddr = action;
+ actionType = ActionValues.ACTION_SET_NW_SRC;
+ }
+
+ /**
+ * Set the action to set the IPv4 source address.
+ *
+ * @param addr the IPv4 address to set as the IPv4 source address.
+ */
+ public void setActionSetIPv4SrcAddr(IPv4 addr) {
+ actionSetIPv4SrcAddr = new ActionSetIPv4Addr(addr);
+ actionType = ActionValues.ACTION_SET_NW_SRC;
+ }
+
+ /**
+ * Get the action to set the IPv4 destination address.
+ *
+ * @return the action to set the IPv4 destination address.
+ */
+ @JsonProperty("actionSetIPv4DstAddr")
+ public ActionSetIPv4Addr actionSetIPv4DstAddr() {
+ return actionSetIPv4DstAddr;
+ }
+
+ /**
+ * Set the action to set the IPv4 destination address.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetIPv4DstAddr")
+ public void setActionSetIPv4DstAddr(ActionSetIPv4Addr action) {
+ actionSetIPv4DstAddr = action;
+ actionType = ActionValues.ACTION_SET_NW_DST;
+ }
+
+ /**
+ * Set the action to set the IPv4 destination address.
+ *
+ * @param addr the IPv4 address to set as the IPv4 destination address.
+ */
+ public void setActionSetIPv4DstAddr(IPv4 addr) {
+ actionSetIPv4DstAddr = new ActionSetIPv4Addr(addr);
+ actionType = ActionValues.ACTION_SET_NW_DST;
+ }
+
+ /**
+ * Get the action to set the IP ToS (DSCP field, 6 bits).
+ *
+ * @return the action to set the IP ToS (DSCP field, 6 bits).
+ */
+ @JsonProperty("actionSetIpToS")
+ public ActionSetIpToS actionSetIpToS() {
+ return actionSetIpToS;
+ }
+
+ /**
+ * Set the action to set the IP ToS (DSCP field, 6 bits).
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetIpToS")
+ public void setActionSetIpToS(ActionSetIpToS action) {
+ actionSetIpToS = action;
+ actionType = ActionValues.ACTION_SET_NW_TOS;
+ }
+
+ /**
+ * Set the action to set the IP ToS (DSCP field, 6 bits).
+ *
+ * @param ipToS the IP ToS (DSCP field, 6 bits) to set.
+ */
+ public void setActionSetIpToS(byte ipToS) {
+ actionSetIpToS = new ActionSetIpToS(ipToS);
+ actionType = ActionValues.ACTION_SET_NW_TOS;
+ }
+
+ /**
+ * Get the action to set the TCP/UDP source port.
+ *
+ * @return the action to set the TCP/UDP source port.
+ */
+ @JsonProperty("actionSetTcpUdpSrcPort")
+ public ActionSetTcpUdpPort actionSetTcpUdpSrcPort() {
+ return actionSetTcpUdpSrcPort;
+ }
+
+ /**
+ * Set the action to set the TCP/UDP source port.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetTcpUdpSrcPort")
+ public void setActionSetTcpUdpSrcPort(ActionSetTcpUdpPort action) {
+ actionSetTcpUdpSrcPort = action;
+ actionType = ActionValues.ACTION_SET_TP_SRC;
+ }
+
+ /**
+ * Set the action to set the TCP/UDP source port.
+ *
+ * @param port the TCP/UDP port to set as the TCP/UDP source port.
+ */
+ public void setActionSetTcpUdpSrcPort(short port) {
+ actionSetTcpUdpSrcPort = new ActionSetTcpUdpPort(port);
+ actionType = ActionValues.ACTION_SET_TP_SRC;
+ }
+
+ /**
+ * Get the action to set the TCP/UDP destination port.
+ *
+ * @return the action to set the TCP/UDP destination port.
+ */
+ @JsonProperty("actionSetTcpUdpDstPort")
+ public ActionSetTcpUdpPort actionSetTcpUdpDstPort() {
+ return actionSetTcpUdpDstPort;
+ }
+
+ /**
+ * Set the action to set the TCP/UDP destination port.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionSetTcpUdpDstPort")
+ public void setActionSetTcpUdpDstPort(ActionSetTcpUdpPort action) {
+ actionSetTcpUdpDstPort = action;
+ actionType = ActionValues.ACTION_SET_TP_DST;
+ }
+
+ /**
+ * Set the action to set the TCP/UDP destination port.
+ *
+ * @param port the TCP/UDP port to set as the TCP/UDP destination port.
+ */
+ public void setActionSetTcpUdpDstPort(short port) {
+ actionSetTcpUdpDstPort = new ActionSetTcpUdpPort(port);
+ actionType = ActionValues.ACTION_SET_TP_DST;
+ }
+
+ /**
+ * Get the action to output to queue on a port.
+ *
+ * @return the action to output to queue on a port.
+ */
+ @JsonProperty("actionEnqueue")
+ public ActionEnqueue actionEnqueue() { return actionEnqueue; }
+
+ /**
+ * Set the action to output to queue on a port.
+ *
+ * @param action the action to set.
+ */
+ @JsonProperty("actionEnqueue")
+ public void setActionEnqueue(ActionEnqueue action) {
+ actionEnqueue = action;
+ actionType = ActionValues.ACTION_ENQUEUE;
+ }
+
+ /**
+ * Set the action to output to queue on a port.
+ *
+ * @param port the port to set.
+ * @param int queueId the queue ID to set.
+ */
+ public void setActionEnqueue(Port port, int queueId) {
+ actionEnqueue = new ActionEnqueue(port, queueId);
+ actionType = ActionValues.ACTION_ENQUEUE;
+ }
+
+ /**
+ * Convert the set of actions to a string.
+ *
+ * The string has the following form:
+ * [type=XXX action=XXX]
+ *
+ * @return the set of actions as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ ret += "type=" + actionType;
+ switch (actionType) {
+ case ACTION_OUTPUT:
+ ret += " action=" + actionOutput.toString();
+ break;
+ case ACTION_SET_VLAN_VID:
+ ret += " action=" + actionSetVlanId.toString();
+ break;
+ case ACTION_SET_VLAN_PCP:
+ ret += " action=" + actionSetVlanPriority.toString();
+ break;
+ case ACTION_STRIP_VLAN:
+ ret += " action=" + actionStripVlan.toString();
+ break;
+ case ACTION_SET_DL_SRC:
+ ret += " action=" + actionSetEthernetSrcAddr.toString();
+ break;
+ case ACTION_SET_DL_DST:
+ ret += " action=" + actionSetEthernetDstAddr.toString();
+ break;
+ case ACTION_SET_NW_SRC:
+ ret += " action=" + actionSetIPv4SrcAddr.toString();
+ break;
+ case ACTION_SET_NW_DST:
+ ret += " action=" + actionSetIPv4DstAddr.toString();
+ break;
+ case ACTION_SET_NW_TOS:
+ ret += " action=" + actionSetIpToS.toString();
+ break;
+ case ACTION_SET_TP_SRC:
+ ret += " action=" + actionSetTcpUdpSrcPort.toString();
+ break;
+ case ACTION_SET_TP_DST:
+ ret += " action=" + actionSetTcpUdpDstPort.toString();
+ break;
+ case ACTION_ENQUEUE:
+ ret += " action=" + actionEnqueue.toString();
+ break;
+ }
+ ret += "]";
+
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryErrorState.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryErrorState.java
new file mode 100644
index 0000000..2e8c448
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryErrorState.java
@@ -0,0 +1,91 @@
+package net.onrc.onos.ofcontroller.util;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Flow Entry error state.
+ */
+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)
+
+ /**
+ * Default constructor.
+ */
+ public FlowEntryErrorState() {
+ this.type = 0;
+ this.code = 0;
+ }
+
+ /**
+ * Constructor for a given error type and code.
+ *
+ * @param type the error type to use.
+ * @param code the error code to use.
+ */
+ public FlowEntryErrorState(short type, short code) {
+ this.type = type;
+ this.code = code;
+ }
+
+ /**
+ * Get the error type.
+ *
+ * @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.
+ * @param code the error code to use.
+ */
+ public void setValue(short type, short code) {
+ this.type = type;
+ this.code = code;
+ }
+
+ /**
+ * Convert the error type and code to a string.
+ *
+ * The string has the following form:
+ * [type=1 code=2]
+ *
+ * @return the error type and code as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[type=" + this.type + " code=" + code + "]";
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryId.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryId.java
new file mode 100644
index 0000000..61ddeb0
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryId.java
@@ -0,0 +1,80 @@
+package net.onrc.onos.ofcontroller.util;
+
+import java.math.BigInteger;
+
+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;
+
+ /**
+ * Default constructor.
+ */
+ public FlowEntryId() {
+ this.value = 0;
+ }
+
+ /**
+ * Constructor from an integer value.
+ *
+ * @param value the value to use.
+ */
+ public FlowEntryId(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public FlowEntryId(String value) {
+ //
+ // Use the help of BigInteger to parse strings representing
+ // large unsigned hex long values.
+ //
+ char c = 0;
+ if (value.length() > 2)
+ c = value.charAt(1);
+ if ((c == 'x') || (c == 'X'))
+ this.value = new BigInteger(value.substring(2), 16).longValue();
+ else
+ this.value = Long.decode(value);
+ }
+
+ /**
+ * Get the value of the Flow Entry ID.
+ *
+ * @return the value of the Flow Entry ID.
+ */
+ public long value() { return value; }
+
+ /**
+ * Set the value of the Flow Entry ID.
+ *
+ * @param value the value to set.
+ */
+ public void setValue(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the Flow Entry ID value to a hexadecimal string.
+ *
+ * @return the Flow Entry ID value to a hexadecimal string.
+ */
+ @Override
+ public String toString() {
+ return "0x" + Long.toHexString(this.value);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryMatch.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryMatch.java
new file mode 100644
index 0000000..0b79c01
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryMatch.java
@@ -0,0 +1,711 @@
+package net.onrc.onos.ofcontroller.util;
+
+import net.floodlightcontroller.util.MACAddress;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Flow Entry Matching filter.
+ *
+ * The Flow Entry matching filter that is used to specify
+ * the network data that would be forwarded on the data path from
+ * the source to the destination. Examples: source or destination MAC address,
+ * IP prefix that includes the destination's IP address, etc.
+ */
+public class FlowEntryMatch {
+ /**
+ * A class for storing a value to match.
+ */
+ class Field<T> {
+ /**
+ * Default constructor.
+ */
+ public Field() {
+ this.enabled = false;
+ }
+
+ /**
+ * Constructor for a given value to match.
+ *
+ * @param value the value to match.
+ */
+ public Field(T value) {
+ this.value = value;
+ this.enabled = true;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return the value.
+ */
+ public T value() { return this.value; }
+
+ /**
+ * Enable the matching for a given value.
+ *
+ * @param value the value to set.
+ */
+ public void enableMatch(T value) {
+ this.value = value;
+ this.enabled = true;
+ }
+
+ /**
+ * Disable the matching.
+ */
+ public void disableMatch() {
+ this.enabled = false;
+ }
+
+ /**
+ * Test whether matching is enabled.
+ *
+ * @return true if matching is enabled, otherwise false.
+ */
+ public boolean enabled() { return this.enabled; }
+
+ private T value; // The value to match
+ private boolean enabled; // Set to true, if matching is enabled
+ }
+
+ private Field<Port> inPort; // Matching input switch port
+ private Field<MACAddress> srcMac; // Matching source MAC address
+ private Field<MACAddress> dstMac; // Matching destination MAC address
+ private Field<Short> vlanId; // Matching VLAN ID
+ private Field<Byte> vlanPriority; // Matching VLAN priority
+ private Field<Short> ethernetFrameType; // Matching Ethernet frame type
+ private Field<Byte> ipToS; // Matching IP ToS (DSCP field, 6 bits)
+ private Field<Byte> ipProto; // Matching IP protocol
+ private Field<IPv4Net> srcIPv4Net; // Matching source IPv4 prefix
+ private Field<IPv4Net> dstIPv4Net; // Matching destination IPv4 prefix
+ private Field<Short> srcTcpUdpPort; // Matching source TCP/UDP port
+ private Field<Short> dstTcpUdpPort; // Matching destination TCP/UDP port
+
+ /**
+ * Default constructor.
+ */
+ public FlowEntryMatch() {
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param other the object to copy from.
+ */
+ public FlowEntryMatch(FlowEntryMatch other) {
+ if ((other.inPort != null) && other.inPort.enabled())
+ this.enableInPort(other.inPort.value());
+ if ((other.srcMac != null) && other.srcMac.enabled())
+ this.enableSrcMac(other.srcMac.value());
+ if ((other.dstMac != null) && other.dstMac.enabled())
+ this.enableDstMac(other.dstMac.value());
+ if ((other.vlanId != null) && other.vlanId.enabled())
+ this.enableVlanId(other.vlanId.value());
+ if ((other.vlanPriority != null) && other.vlanPriority.enabled())
+ this.enableVlanPriority(other.vlanPriority.value());
+ if ((other.ethernetFrameType != null) && other.ethernetFrameType.enabled())
+ this.enableEthernetFrameType(other.ethernetFrameType.value());
+ if ((other.ipToS != null) && other.ipToS.enabled())
+ this.enableIpToS(other.ipToS.value());
+ if ((other.ipProto != null) && other.ipProto.enabled())
+ this.enableIpProto(other.ipProto.value());
+ if ((other.srcIPv4Net != null) && other.srcIPv4Net.enabled())
+ this.enableSrcIPv4Net(other.srcIPv4Net.value());
+ if ((other.dstIPv4Net != null) && other.dstIPv4Net.enabled())
+ this.enableDstIPv4Net(other.dstIPv4Net.value());
+ if ((other.srcTcpUdpPort != null) && other.srcTcpUdpPort.enabled())
+ this.enableSrcTcpUdpPort(other.srcTcpUdpPort.value());
+ if ((other.dstTcpUdpPort != null) && other.dstTcpUdpPort.enabled())
+ this.enableDstTcpUdpPort(other.dstTcpUdpPort.value());
+ }
+
+ /**
+ * Get the matching input switch port.
+ *
+ * @return the matching input switch port.
+ */
+ @JsonProperty("inPort")
+ public Port inPort() {
+ if (inPort != null)
+ return inPort.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on input switch port.
+ *
+ * @param inPort the input switch port value to enable for matching.
+ */
+ @JsonProperty("inPort")
+ public void enableInPort(Port inPort) {
+ this.inPort = new Field<Port>(inPort);
+ }
+
+ /**
+ * Disable the matching on input switch port.
+ */
+ public void disableInPort() {
+ this.inPort = null;
+ }
+
+ /**
+ * Test if matching on input switch port is enabled.
+ *
+ * @return true if matching on input switch port is enabled.
+ */
+ @JsonProperty("matchInPort")
+ public boolean matchInPort() {
+ if (inPort != null)
+ return inPort.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching source MAC address.
+ *
+ * @return the matching source MAC address.
+ */
+ @JsonProperty("srcMac")
+ public MACAddress srcMac() {
+ if (srcMac != null)
+ return srcMac.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on source MAC address.
+ *
+ * @param srcMac the source MAC address value to enable for matching.
+ */
+ @JsonProperty("srcMac")
+ public void enableSrcMac(MACAddress srcMac) {
+ this.srcMac = new Field<MACAddress>(srcMac);
+ }
+
+ /**
+ * Disable the matching on source MAC address.
+ */
+ public void disableSrcMac() {
+ this.srcMac = null;
+ }
+
+ /**
+ * Test if matching on source MAC address is enabled.
+ *
+ * @return true if matching on source MAC address is enabled.
+ */
+ @JsonProperty("matchSrcMac")
+ public boolean matchSrcMac() {
+ if (srcMac != null)
+ return srcMac.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching destination MAC address.
+ *
+ * @return the matching destination MAC address.
+ */
+ @JsonProperty("dstMac")
+ public MACAddress dstMac() {
+ if (dstMac != null)
+ return dstMac.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on destination MAC address.
+ *
+ * @param dstMac the destination MAC address value to enable for matching.
+ */
+ @JsonProperty("dstMac")
+ public void enableDstMac(MACAddress dstMac) {
+ this.dstMac = new Field<MACAddress>(dstMac);
+ }
+
+ /**
+ * Disable the matching on destination MAC address.
+ */
+ public void disableDstMac() {
+ this.dstMac = null;
+ }
+
+ /**
+ * Test if matching on destination MAC address is enabled.
+ *
+ * @return true if matching on destination MAC address is enabled.
+ */
+ @JsonProperty("matchDstMac")
+ public boolean matchDstMac() {
+ if (dstMac != null)
+ return dstMac.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching VLAN ID.
+ *
+ * @return the matching VLAN ID.
+ */
+ @JsonProperty("vlanId")
+ public Short vlanId() {
+ if (vlanId != null)
+ return vlanId.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on VLAN ID.
+ *
+ * @param vlanId the VLAN ID value to enable for matching.
+ */
+ @JsonProperty("vlanId")
+ public void enableVlanId(Short vlanId) {
+ this.vlanId = new Field<Short>(vlanId);
+ }
+
+ /**
+ * Disable the matching on VLAN ID.
+ */
+ public void disableVlanId() {
+ this.vlanId = null;
+ }
+
+ /**
+ * Test if matching on VLAN ID is enabled.
+ *
+ * @return true if matching on VLAN ID is enabled.
+ */
+ @JsonProperty("matchVlanId")
+ public boolean matchVlanId() {
+ if (vlanId != null)
+ return vlanId.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching VLAN priority.
+ *
+ * @return the matching VLAN priority.
+ */
+ @JsonProperty("vlanPriority")
+ public Byte vlanPriority() {
+ if (vlanPriority != null)
+ return vlanPriority.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on VLAN priority.
+ *
+ * @param vlanPriority the VLAN priority value to enable for matching.
+ */
+ @JsonProperty("vlanPriority")
+ public void enableVlanPriority(Byte vlanPriority) {
+ this.vlanPriority = new Field<Byte>(vlanPriority);
+ }
+
+ /**
+ * Disable the matching on VLAN priority.
+ */
+ public void disableVlanPriority() {
+ this.vlanPriority = null;
+ }
+
+ /**
+ * Test if matching on VLAN priority is enabled.
+ *
+ * @return true if matching on VLAN priority is enabled.
+ */
+ @JsonProperty("matchVlanPriority")
+ public boolean matchVlanPriority() {
+ if (vlanPriority != null)
+ return vlanPriority.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching Ethernet frame type.
+ *
+ * @return the matching Ethernet frame type.
+ */
+ @JsonProperty("ethernetFrameType")
+ public Short ethernetFrameType() {
+ if (ethernetFrameType != null)
+ return ethernetFrameType.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on Ethernet frame type.
+ *
+ * @param ethernetFrameType the Ethernet frame type value to enable for
+ * matching.
+ */
+ @JsonProperty("ethernetFrameType")
+ public void enableEthernetFrameType(Short ethernetFrameType) {
+ this.ethernetFrameType = new Field<Short>(ethernetFrameType);
+ }
+
+ /**
+ * Disable the matching on Ethernet frame type.
+ */
+ public void disableEthernetFrameType() {
+ this.ethernetFrameType = null;
+ }
+
+ /**
+ * Test if matching on Ethernet frame type is enabled.
+ *
+ * @return true if matching on Ethernet frame type is enabled.
+ */
+ @JsonProperty("matchEthernetFrameType")
+ public boolean matchEthernetFrameType() {
+ if (ethernetFrameType != null)
+ return ethernetFrameType.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching IP ToS (DSCP field, 6 bits)
+ *
+ * @return the matching IP ToS.
+ */
+ @JsonProperty("ipToS")
+ public Byte ipToS() {
+ if (ipToS != null)
+ return ipToS.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on IP ToS (DSCP field, 6 bits).
+ *
+ * @param ipToS the IP ToS value to enable for matching.
+ */
+ @JsonProperty("ipToS")
+ public void enableIpToS(Byte ipToS) {
+ this.ipToS = new Field<Byte>(ipToS);
+ }
+
+ /**
+ * Disable the matching on IP ToS (DSCP field, 6 bits).
+ */
+ public void disableIpToS() {
+ this.ipToS = null;
+ }
+
+ /**
+ * Test if matching on IP ToS (DSCP field, 6 bits) is enabled.
+ *
+ * @return true if matching on IP ToS is enabled.
+ */
+ @JsonProperty("matchIpToS")
+ public boolean matchIpToS() {
+ if (ipToS != null)
+ return ipToS.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching IP protocol.
+ *
+ * @return the matching IP protocol.
+ */
+ @JsonProperty("ipProto")
+ public Byte ipProto() {
+ if (ipProto != null)
+ return ipProto.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on IP protocol.
+ *
+ * @param ipProto the IP protocol value to enable for matching.
+ */
+ @JsonProperty("ipProto")
+ public void enableIpProto(Byte ipProto) {
+ this.ipProto = new Field<Byte>(ipProto);
+ }
+
+ /**
+ * Disable the matching on IP protocol.
+ */
+ public void disableIpProto() {
+ this.ipProto = null;
+ }
+
+ /**
+ * Test if matching on IP protocol is enabled.
+ *
+ * @return true if matching on IP protocol is enabled.
+ */
+ @JsonProperty("matchIpProto")
+ public boolean matchIpProto() {
+ if (ipProto != null)
+ return ipProto.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching source IPv4 prefix.
+ *
+ * @return the matching source IPv4 prefix.
+ */
+ @JsonProperty("srcIPv4Net")
+ public IPv4Net srcIPv4Net() {
+ if (srcIPv4Net != null)
+ return srcIPv4Net.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on source IPv4 prefix.
+ *
+ * @param srcIPv4Net the source IPv4 prefix value to enable for matching.
+ */
+ @JsonProperty("srcIPv4Net")
+ public void enableSrcIPv4Net(IPv4Net srcIPv4Net) {
+ this.srcIPv4Net = new Field<IPv4Net>(srcIPv4Net);
+ }
+
+ /**
+ * Disable the matching on source IPv4 prefix.
+ */
+ public void disableSrcIPv4Net() {
+ this.srcIPv4Net = null;
+ }
+
+ /**
+ * Test if matching on source IPv4 prefix is enabled.
+ *
+ * @return true if matching on source IPv4 prefix is enabled.
+ */
+ @JsonProperty("matchSrcIPv4Net")
+ public boolean matchSrcIPv4Net() {
+ if (srcIPv4Net != null)
+ return srcIPv4Net.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching destination IPv4 prefix.
+ *
+ * @return the matching destination IPv4 prefix.
+ */
+ @JsonProperty("dstIPv4Net")
+ public IPv4Net dstIPv4Net() {
+ if (dstIPv4Net != null)
+ return dstIPv4Net.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on destination IPv4 prefix.
+ *
+ * @param dstIPv4Net the destination IPv4 prefix value to enable for
+ * matching.
+ */
+ @JsonProperty("dstIPv4Net")
+ public void enableDstIPv4Net(IPv4Net dstIPv4Net) {
+ this.dstIPv4Net = new Field<IPv4Net>(dstIPv4Net);
+ }
+
+ /**
+ * Disable the matching on destination IPv4 prefix.
+ */
+ public void disableDstIPv4Net() {
+ this.dstIPv4Net = null;
+ }
+
+ /**
+ * Test if matching on destination IPv4 prefix is enabled.
+ *
+ * @return true if matching on destination IPv4 prefix is enabled.
+ */
+ @JsonProperty("matchDstIPv4Net")
+ public boolean matchDstIPv4Net() {
+ if (dstIPv4Net != null)
+ return dstIPv4Net.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching source TCP/UDP port.
+ *
+ * @return the matching source TCP/UDP port.
+ */
+ @JsonProperty("srcTcpUdpPort")
+ public Short srcTcpUdpPort() {
+ if (srcTcpUdpPort != null)
+ return srcTcpUdpPort.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on source TCP/UDP port.
+ *
+ * @param srcTcpUdpPort the source TCP/UDP port to enable for matching.
+ */
+ @JsonProperty("srcTcpUdpPort")
+ public void enableSrcTcpUdpPort(Short srcTcpUdpPort) {
+ this.srcTcpUdpPort = new Field<Short>(srcTcpUdpPort);
+ }
+
+ /**
+ * Disable the matching on source TCP/UDP port.
+ */
+ public void disableSrcTcpUdpPort() {
+ this.srcTcpUdpPort = null;
+ }
+
+ /**
+ * Test if matching on source TCP/UDP port is enabled.
+ *
+ * @return true if matching on source TCP/UDP port is enabled.
+ */
+ @JsonProperty("matchSrcTcpUdpPort")
+ public boolean matchSrcTcpUdpPort() {
+ if (srcTcpUdpPort != null)
+ return srcTcpUdpPort.enabled();
+ return false;
+ }
+
+ /**
+ * Get the matching destination TCP/UDP port.
+ *
+ * @return the matching destination TCP/UDP port.
+ */
+ @JsonProperty("dstTcpUdpPort")
+ public Short dstTcpUdpPort() {
+ if (dstTcpUdpPort != null)
+ return dstTcpUdpPort.value();
+ return null;
+ }
+
+ /**
+ * Enable the matching on destination TCP/UDP port.
+ *
+ * @param dstTcpUdpPort the destination TCP/UDP port to enable for
+ * matching.
+ */
+ @JsonProperty("dstTcpUdpPort")
+ public void enableDstTcpUdpPort(Short dstTcpUdpPort) {
+ this.dstTcpUdpPort = new Field<Short>(dstTcpUdpPort);
+ }
+
+ /**
+ * Disable the matching on destination TCP/UDP port.
+ */
+ public void disableDstTcpUdpPort() {
+ this.dstTcpUdpPort = null;
+ }
+
+ /**
+ * Test if matching on destination TCP/UDP port is enabled.
+ *
+ * @return true if matching on destination TCP/UDP port is enabled.
+ */
+ @JsonProperty("matchDstTcpUdpPort")
+ public boolean matchDstTcpUdpPort() {
+ if (dstTcpUdpPort != null)
+ return dstTcpUdpPort.enabled();
+ return false;
+ }
+
+ /**
+ * Convert the matching filter to a string.
+ *
+ * The string has the following form:
+ * [srcMac=XXX dstMac=XXX srcIPv4Net=XXX dstIPv4Net=XXX]
+ *
+ * @return the matching filter as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[";
+ boolean addSpace = false;
+
+ //
+ // Conditionally add only those matching fields that are enabled
+ //
+ if (matchInPort()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "inPort=" + this.inPort().toString();
+ }
+ if (matchSrcMac()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "srcMac=" + this.srcMac().toString();
+ }
+ if (matchDstMac()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "dstMac=" + this.dstMac().toString();
+ }
+ if (matchVlanId()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "vlanId=" + this.vlanId().toString();
+ }
+ if (matchVlanPriority()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "vlanPriority=" + this.vlanPriority().toString();
+ }
+ if (matchEthernetFrameType()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "ethernetFrameType=" + this.ethernetFrameType().toString();
+ }
+ if (matchIpToS()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "ipToS=" + this.ipToS().toString();
+ }
+ if (matchIpProto()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "ipProto=" + this.ipProto().toString();
+ }
+ if (matchSrcIPv4Net()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "srcIPv4Net=" + this.srcIPv4Net().toString();
+ }
+ if (matchDstIPv4Net()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "dstIPv4Net=" + this.dstIPv4Net().toString();
+ }
+ if (matchSrcTcpUdpPort()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "srcTcpUdpPort=" + this.srcTcpUdpPort().toString();
+ }
+ if (matchDstTcpUdpPort()) {
+ if (addSpace)
+ ret += " ";
+ addSpace = true;
+ ret += "dstTcpUdpPort=" + this.dstTcpUdpPort().toString();
+ }
+
+ ret += "]";
+
+ return ret;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntrySwitchState.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntrySwitchState.java
new file mode 100644
index 0000000..a69fdac
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntrySwitchState.java
@@ -0,0 +1,12 @@
+package net.onrc.onos.ofcontroller.util;
+
+/**
+ * The Flow Entry state as set by the controller.
+ */
+public enum FlowEntrySwitchState {
+ FE_SWITCH_UNKNOWN, // Initialization value: state unknown
+ FE_SWITCH_NOT_UPDATED, // Switch not updated with this entry
+ FE_SWITCH_UPDATE_IN_PROGRESS, // Switch update in progress
+ FE_SWITCH_UPDATED, // Switch updated with this entry
+ FE_SWITCH_UPDATE_FAILED // Error updating the switch with this entry
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryUserState.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryUserState.java
new file mode 100644
index 0000000..e3b64f0
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowEntryUserState.java
@@ -0,0 +1,11 @@
+package net.onrc.onos.ofcontroller.util;
+
+/**
+ * The Flow Entry state as set by the user (via the ONOS API).
+ */
+public enum FlowEntryUserState {
+ FE_USER_UNKNOWN, // Initialization value: state unknown
+ FE_USER_ADD, // Flow entry that is added
+ FE_USER_MODIFY, // Flow entry that is modified
+ FE_USER_DELETE // Flow entry that is deleted
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowId.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowId.java
new file mode 100644
index 0000000..8592b36
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowId.java
@@ -0,0 +1,80 @@
+package net.onrc.onos.ofcontroller.util;
+
+import java.math.BigInteger;
+
+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;
+
+ /**
+ * Default constructor.
+ */
+ public FlowId() {
+ this.value = 0;
+ }
+
+ /**
+ * Constructor from an integer value.
+ *
+ * @param value the value to use.
+ */
+ public FlowId(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public FlowId(String value) {
+ //
+ // Use the help of BigInteger to parse strings representing
+ // large unsigned hex long values.
+ //
+ char c = 0;
+ if (value.length() > 2)
+ c = value.charAt(1);
+ if ((c == 'x') || (c == 'X'))
+ this.value = new BigInteger(value.substring(2), 16).longValue();
+ else
+ this.value = Long.decode(value);
+ }
+
+ /**
+ * Get the value of the Flow ID.
+ *
+ * @return the value of the Flow ID.
+ */
+ public long value() { return value; }
+
+ /**
+ * Set the value of the Flow ID.
+ *
+ * @param value the value to set.
+ */
+ public void setValue(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the Flow ID value to a hexadecimal string.
+ *
+ * @return the Flow ID value to a hexadecimal string.
+ */
+ @Override
+ public String toString() {
+ return "0x" + Long.toHexString(this.value);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java
new file mode 100644
index 0000000..29898e6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/FlowPath.java
@@ -0,0 +1,222 @@
+package net.onrc.onos.ofcontroller.util;
+
+import java.util.ArrayList;
+
+import net.floodlightcontroller.util.MACAddress;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.util.FlowEntryMatch;
+import net.onrc.onos.ofcontroller.util.FlowId;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing the Flow Path.
+ */
+public class FlowPath implements Comparable<FlowPath> {
+ private FlowId flowId; // The Flow ID
+ private CallerId installerId; // The Caller ID of the path installer
+ private DataPath dataPath; // The data path
+ private FlowEntryMatch flowEntryMatch; // Common Flow Entry Match for all
+ // Flow Entries
+
+ /**
+ * Default constructor.
+ */
+ public FlowPath() {
+ dataPath = new DataPath();
+ }
+
+ /**
+ * Constructor to instantiate from object in Network Map
+ */
+ public FlowPath(IFlowPath flowObj) {
+ dataPath = new DataPath();
+ this.setFlowId(new FlowId(flowObj.getFlowId()));
+ this.setInstallerId(new CallerId(flowObj.getInstallerId()));
+ this.dataPath().srcPort().setDpid(new Dpid(flowObj.getSrcSwitch()));
+ this.dataPath().srcPort().setPort(new Port(flowObj.getSrcPort()));
+ this.dataPath().dstPort().setDpid(new Dpid(flowObj.getDstSwitch()));
+ this.dataPath().dstPort().setPort(new Port(flowObj.getDstPort()));
+ //
+ // Extract the match conditions that are common for all Flow Entries
+ //
+ {
+ FlowEntryMatch match = new FlowEntryMatch();
+ Short matchEthernetFrameType = flowObj.getMatchEthernetFrameType();
+ if (matchEthernetFrameType != null)
+ match.enableEthernetFrameType(matchEthernetFrameType);
+ String matchSrcIPv4Net = flowObj.getMatchSrcIPv4Net();
+ if (matchSrcIPv4Net != null)
+ match.enableSrcIPv4Net(new IPv4Net(matchSrcIPv4Net));
+ String matchDstIPv4Net = flowObj.getMatchDstIPv4Net();
+ if (matchDstIPv4Net != null)
+ match.enableDstIPv4Net(new IPv4Net(matchDstIPv4Net));
+ String matchSrcMac = flowObj.getMatchSrcMac();
+ if (matchSrcMac != null)
+ match.enableSrcMac(MACAddress.valueOf(matchSrcMac));
+ String matchDstMac = flowObj.getMatchDstMac();
+ if (matchDstMac != null)
+ match.enableDstMac(MACAddress.valueOf(matchDstMac));
+ this.setFlowEntryMatch(match);
+ }
+
+ //
+ // Extract all Flow Entries
+ //
+ Iterable<IFlowEntry> flowEntries = flowObj.getFlowEntries();
+ for (IFlowEntry flowEntryObj : flowEntries) {
+ FlowEntry flowEntry = new FlowEntry();
+ flowEntry.setFlowEntryId(new FlowEntryId(flowEntryObj.getFlowEntryId()));
+ flowEntry.setDpid(new Dpid(flowEntryObj.getSwitchDpid()));
+
+ //
+ // Extract the match conditions
+ //
+ FlowEntryMatch match = new FlowEntryMatch();
+ Short matchInPort = flowEntryObj.getMatchInPort();
+ if (matchInPort != null)
+ match.enableInPort(new Port(matchInPort));
+ Short matchEthernetFrameType = flowEntryObj.getMatchEthernetFrameType();
+ if (matchEthernetFrameType != null)
+ match.enableEthernetFrameType(matchEthernetFrameType);
+ String matchSrcIPv4Net = flowEntryObj.getMatchSrcIPv4Net();
+ if (matchSrcIPv4Net != null)
+ match.enableSrcIPv4Net(new IPv4Net(matchSrcIPv4Net));
+ String matchDstIPv4Net = flowEntryObj.getMatchDstIPv4Net();
+ if (matchDstIPv4Net != null)
+ match.enableDstIPv4Net(new IPv4Net(matchDstIPv4Net));
+ String matchSrcMac = flowEntryObj.getMatchSrcMac();
+ if (matchSrcMac != null)
+ match.enableSrcMac(MACAddress.valueOf(matchSrcMac));
+ String matchDstMac = flowEntryObj.getMatchDstMac();
+ if (matchDstMac != null)
+ match.enableDstMac(MACAddress.valueOf(matchDstMac));
+ flowEntry.setFlowEntryMatch(match);
+
+ //
+ // Extract the actions
+ //
+ ArrayList<FlowEntryAction> actions = new ArrayList<FlowEntryAction>();
+ Short actionOutputPort = flowEntryObj.getActionOutput();
+ if (actionOutputPort != null) {
+ FlowEntryAction action = new FlowEntryAction();
+ action.setActionOutput(new Port(actionOutputPort));
+ actions.add(action);
+ }
+ flowEntry.setFlowEntryActions(actions);
+
+ String userState = flowEntryObj.getUserState();
+ flowEntry.setFlowEntryUserState(FlowEntryUserState.valueOf(userState));
+ String switchState = flowEntryObj.getSwitchState();
+ flowEntry.setFlowEntrySwitchState(FlowEntrySwitchState.valueOf(switchState));
+ //
+ // TODO: Take care of the FlowEntryMatch, FlowEntryAction set,
+ // and FlowEntryErrorState.
+ //
+ this.dataPath().flowEntries().add(flowEntry);
+ }
+ }
+
+ /**
+ * Get the flow path Flow ID.
+ *
+ * @return the flow path Flow ID.
+ */
+ @JsonProperty("flowId")
+ public FlowId flowId() { return flowId; }
+
+ /**
+ * Set the flow path Flow ID.
+ *
+ * @param flowId the flow path Flow ID to set.
+ */
+ @JsonProperty("flowId")
+ public void setFlowId(FlowId flowId) {
+ this.flowId = flowId;
+ }
+
+ /**
+ * Get the Caller ID of the flow path installer.
+ *
+ * @return the Caller ID of the flow path installer.
+ */
+ @JsonProperty("installerId")
+ public CallerId installerId() { return installerId; }
+
+ /**
+ * Set the Caller ID of the flow path installer.
+ *
+ * @param installerId the Caller ID of the flow path installer.
+ */
+ @JsonProperty("installerId")
+ public void setInstallerId(CallerId installerId) {
+ this.installerId = installerId;
+ }
+
+ /**
+ * Get the flow path's data path.
+ *
+ * @return the flow path's data path.
+ */
+ @JsonProperty("dataPath")
+ public DataPath dataPath() { return dataPath; }
+
+ /**
+ * Set the flow path's data path.
+ *
+ * @param dataPath the flow path's data path to set.
+ */
+ @JsonProperty("dataPath")
+ public void setDataPath(DataPath dataPath) {
+ this.dataPath = dataPath;
+ }
+
+ /**
+ * Get the flow path's match conditions common for all Flow Entries.
+ *
+ * @return the flow path's match conditions common for all Flow Entries.
+ */
+ @JsonProperty("flowEntryMatch")
+ public FlowEntryMatch flowEntryMatch() { return flowEntryMatch; }
+
+ /**
+ * Set the flow path's match conditions common for all Flow Entries.
+ *
+ * @param flowEntryMatch the flow path's match conditions common for all
+ * Flow Entries.
+ */
+ @JsonProperty("flowEntryMatch")
+ public void setFlowEntryMatch(FlowEntryMatch flowEntryMatch) {
+ this.flowEntryMatch = flowEntryMatch;
+ }
+
+ /**
+ * Convert the flow path to a string.
+ *
+ * The string has the following form:
+ * [flowId=XXX installerId=XXX dataPath=XXX]
+ *
+ * @return the flow path as a string.
+ */
+ @Override
+ public String toString() {
+ String ret = "[flowId=" + this.flowId.toString();
+ ret += " installerId=" + this.installerId.toString();
+ if (dataPath != null)
+ ret += " dataPath=" + this.dataPath.toString();
+ if (flowEntryMatch != null)
+ ret += " flowEntryMatch=" + this.flowEntryMatch.toString();
+ ret += "]";
+ return ret;
+ }
+
+ /**
+ * CompareTo method to order flowPath by Id
+ */
+ @Override
+ public int compareTo(FlowPath f) {
+ return (int) (this.flowId.value() - f.flowId.value());
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/IPv4.java b/src/main/java/net/onrc/onos/ofcontroller/util/IPv4.java
new file mode 100644
index 0000000..69f0ef5
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/IPv4.java
@@ -0,0 +1,80 @@
+package net.onrc.onos.ofcontroller.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;
+
+ /**
+ * Default constructor.
+ */
+ public IPv4() {
+ this.value = 0;
+ }
+
+ /**
+ * Constructor from an integer value.
+ *
+ * @param value the value to use.
+ */
+ public IPv4(int value) {
+ this.value = value;
+ }
+
+ /**
+ * 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.
+ */
+ public int value() { return value; }
+
+ /**
+ * Set the value of the IPv4 address.
+ *
+ * @param value the value to set.
+ */
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the IPv4 value to a '.' separated string.
+ *
+ * @return the IPv4 value as a '.' separated string.
+ */
+ @Override
+ public String toString() {
+ return ((this.value >> 24) & 0xFF) + "." +
+ ((this.value >> 16) & 0xFF) + "." +
+ ((this.value >> 8) & 0xFF) + "." +
+ (this.value & 0xFF);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/IPv4Net.java b/src/main/java/net/onrc/onos/ofcontroller/util/IPv4Net.java
new file mode 100644
index 0000000..bc516f5
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/IPv4Net.java
@@ -0,0 +1,105 @@
+package net.onrc.onos.ofcontroller.util;
+
+import net.floodlightcontroller.util.serializers.IPv4NetDeserializer;
+import net.floodlightcontroller.util.serializers.IPv4NetSerializer;
+import net.onrc.onos.ofcontroller.util.IPv4;
+
+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
+ private short prefixLen; // The prefix length
+
+ /**
+ * Default constructor.
+ */
+ public IPv4Net() {
+ this.prefixLen = 0;
+ }
+
+ /**
+ * Constructor for a given address and prefix length.
+ *
+ * @param address the address to use.
+ * @param prefixLen the prefix length to use.
+ */
+ public IPv4Net(IPv4 address, short prefixLen) {
+ this.address = address;
+ this.prefixLen = prefixLen;
+ }
+
+ /**
+ * 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.
+ */
+ 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.
+ */
+ 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.
+ * @param prefixLen the prefix length to use.
+ */
+ public void setValue(IPv4 address, short prefixLen) {
+ this.address = address;
+ this.prefixLen = prefixLen;
+ }
+
+ /**
+ * Convert the IPv4Net value to an "address/prefixLen" string.
+ *
+ * @return the IPv4Net value as an "address/prefixLen" string.
+ */
+ @Override
+ public String toString() {
+ return this.address.toString() + "/" + this.prefixLen;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/IPv6.java b/src/main/java/net/onrc/onos/ofcontroller/util/IPv6.java
new file mode 100644
index 0000000..2855a46
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/IPv6.java
@@ -0,0 +1,105 @@
+package net.onrc.onos.ofcontroller.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
+ private long valueLow; // The lower (less significant) 64 bits
+
+ /**
+ * Default constructor.
+ */
+ public IPv6() {
+ this.valueHigh = 0;
+ this.valueLow = 0;
+ }
+
+ /**
+ * Constructor from integer values.
+ *
+ * @param valueHigh the higher (more significant) 64 bits of the address.
+ * @param valueLow the lower (less significant) 64 bits of the address.
+ */
+ public IPv6(long valueHigh, long valueLow) {
+ this.valueHigh = valueHigh;
+ this.valueLow = valueLow;
+ }
+
+ /**
+ * 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
+ * address.
+ */
+ 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
+ * address.
+ */
+ 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.
+ * @param valueLow the lower (less significant) 64 bits of the address.
+ */
+ public void setValue(long valueHigh, long valueLow) {
+ this.valueHigh = valueHigh;
+ this.valueLow = valueLow;
+ }
+
+ /**
+ * Convert the IPv6 value to a ':' separated string.
+ *
+ * @return the IPv6 value as a ':' separated string.
+ */
+ @Override
+ public String toString() {
+ return HexString.toHexString(this.valueHigh) + ":" +
+ HexString.toHexString(this.valueLow);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/IPv6Net.java b/src/main/java/net/onrc/onos/ofcontroller/util/IPv6Net.java
new file mode 100644
index 0000000..7700591
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/IPv6Net.java
@@ -0,0 +1,105 @@
+package net.onrc.onos.ofcontroller.util;
+
+import net.floodlightcontroller.util.serializers.IPv6NetDeserializer;
+import net.floodlightcontroller.util.serializers.IPv6NetSerializer;
+import net.onrc.onos.ofcontroller.util.IPv6;
+
+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
+ private short prefixLen; // The prefix length
+
+ /**
+ * Default constructor.
+ */
+ public IPv6Net() {
+ this.prefixLen = 0;
+ }
+
+ /**
+ * Constructor for a given address and prefix length.
+ *
+ * @param address the address to use.
+ * @param prefixLen the prefix length to use.
+ */
+ public IPv6Net(IPv6 address, short prefixLen) {
+ this.address = address;
+ this.prefixLen = prefixLen;
+ }
+
+ /**
+ * 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.
+ */
+ 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.
+ */
+ 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.
+ * @param prefixLen the prefix length to use.
+ */
+ public void setValue(IPv6 address, short prefixLen) {
+ this.address = address;
+ this.prefixLen = prefixLen;
+ }
+
+ /**
+ * Convert the IPv6Net value to an "address/prefixLen" string.
+ *
+ * @return the IPv6Net value as an "address/prefixLen" string.
+ */
+ @Override
+ public String toString() {
+ return this.address.toString() + "/" + this.prefixLen;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/Port.java b/src/main/java/net/onrc/onos/ofcontroller/util/Port.java
new file mode 100644
index 0000000..34c807d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/Port.java
@@ -0,0 +1,134 @@
+package net.onrc.onos.ofcontroller.util;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing a network port of a switch.
+ */
+
+public class Port {
+ /**
+ * Special port values.
+ *
+ * Those values are taken as-is from the OpenFlow-v1.0.0 specification
+ * (pp 18-19).
+ */
+ public enum PortValues {
+ /* Maximum number of physical switch ports. */
+ PORT_MAX ((short)0xff00),
+
+ /* Fake output "ports". */
+
+ /* Send the packet out the input port. This
+ virtual port must be explicitly used
+ in order to send back out of the input
+ port. */
+ PORT_IN_PORT ((short)0xfff8),
+
+ /* Perform actions in flow table.
+ NB: This can only be the destination
+ port for packet-out messages. */
+ PORT_TABLE ((short)0xfff9),
+
+ /* Process with normal L2/L3 switching. */
+ PORT_NORMAL ((short)0xfffa),
+
+ /* All physical ports except input port and
+ those disabled by STP. */
+ PORT_FLOOD ((short)0xfffb),
+
+ /* All physical ports except input port. */
+ PORT_ALL ((short)0xfffc),
+
+ /* Send to controller. */
+ PORT_CONTROLLER ((short)0xfffd),
+
+ /* Local openflow "port". */
+ PORT_LOCAL ((short)0xfffe),
+
+ /* Not associated with a physical port. */
+ PORT_NONE ((short)0xffff);
+
+ private final short value; // The value
+
+ /**
+ * Constructor for a given value.
+ *
+ * @param value the value to use for the initialization.
+ */
+ private PortValues(short value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the value as a short integer.
+ *
+ * @return the value as a short integer.
+ */
+ private short value() { return this.value; }
+ }
+
+ private short value;
+
+ /**
+ * Default constructor.
+ */
+ public Port() {
+ this.value = 0;
+ }
+
+ /**
+ * Constructor from another entry.
+ *
+ * @param other the other entry to use.
+ */
+ public Port(Port other) {
+ this.value = other.value();
+ }
+
+ /**
+ * Constructor from a short integer value.
+ *
+ * @param value the value to use.
+ */
+ public Port(short value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor from a PortValues enum value.
+ *
+ * @param value the value to use.
+ */
+ public Port(PortValues value) {
+ this.value = value.value();
+ }
+
+ /**
+ * Get the value of the port.
+ *
+ * @return the value of the port.
+ */
+ @JsonProperty("value")
+ public short value() { return value; }
+
+ /**
+ * Set the value of the port.
+ *
+ * @param value the value to set.
+ */
+ @JsonProperty("value")
+ public void setValue(short value) {
+ this.value = value;
+ }
+
+ /**
+ * Convert the port value to a string.
+ *
+ * @return the port value as a string.
+ */
+ @Override
+ public String toString() {
+ return Short.toString(this.value);
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java b/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java
new file mode 100644
index 0000000..afc2af3
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/SwitchPort.java
@@ -0,0 +1,90 @@
+package net.onrc.onos.ofcontroller.util;
+
+import net.onrc.onos.ofcontroller.util.Port;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * The class representing a Switch-Port.
+ */
+public class SwitchPort {
+ private Dpid dpid; // The DPID of the switch
+ private Port port; // The port of the switch
+
+ /**
+ * Default constructor.
+ */
+ public SwitchPort() {
+ }
+
+ /**
+ * Constructor for a given DPID and a port.
+ *
+ * @param dpid the DPID to use.
+ * @param port the port to use.
+ */
+ public SwitchPort(Dpid dpid, Port port) {
+ this.dpid = dpid;
+ this.port = port;
+ }
+
+ /**
+ * Get the DPID value of the Switch-Port.
+ *
+ * @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.
+ * @param port the port to use.
+ */
+ public void setValue(Dpid dpid, Port port) {
+ this.dpid = dpid;
+ this.port = port;
+ }
+
+ /**
+ * Convert the Switch-Port value to a string.
+ *
+ * The string has the following form:
+ * 01:02:03:04:05:06:07:08/1234
+ *
+ * @return the Switch-Port value as a string.
+ */
+ @Override
+ public String toString() {
+ return this.dpid.toString() + "/" + this.port;
+ }
+}
diff --git a/src/main/java/net/onrc/onos/util/GraphDBUtils.java b/src/main/java/net/onrc/onos/util/GraphDBUtils.java
index 134dc12..92befe6 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBUtils.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBUtils.java
@@ -3,14 +3,14 @@
import java.util.ArrayList;
import java.util.List;
-import net.floodlightcontroller.util.FlowEntryId;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.blueprints.Vertex;
diff --git a/src/main/java/net/onrc/onos/util/IDBUtils.java b/src/main/java/net/onrc/onos/util/IDBUtils.java
index 0fe8f25..a16e136 100644
--- a/src/main/java/net/onrc/onos/util/IDBUtils.java
+++ b/src/main/java/net/onrc/onos/util/IDBUtils.java
@@ -1,12 +1,12 @@
package net.onrc.onos.util;
-import net.floodlightcontroller.util.FlowEntryId;
-import net.floodlightcontroller.util.FlowId;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.util.FlowEntryId;
+import net.onrc.onos.ofcontroller.util.FlowId;
public interface IDBUtils {
public ISwitchObject searchSwitch(GraphDBConnection conn, String dpid);