Allowed flows to be permanent
Change-Id: I61952fe4cbad98be53094c7ec4a474868384b616
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java
index 905469f..cf448cb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowEntry.java
@@ -27,7 +27,7 @@
TrafficTreatment treatment, int priority, FlowEntryState state,
long life, long packets, long bytes, long flowId,
int timeout) {
- super(deviceId, selector, treatment, priority, flowId, timeout);
+ super(deviceId, selector, treatment, priority, flowId, timeout, false);
this.state = state;
this.life = life;
this.packets = packets;
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index 6ecbbbc..a6593a8 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -24,16 +24,18 @@
private final short appId;
private final int timeout;
+ private final boolean permanent;
public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
TrafficTreatment treatment, int priority, long flowId,
- int timeout) {
+ int timeout, boolean permanent) {
this.deviceId = deviceId;
this.priority = priority;
this.selector = selector;
this.treatment = treatment;
this.timeout = timeout;
+ this.permanent = permanent;
this.created = System.currentTimeMillis();
this.appId = (short) (flowId >>> 48);
@@ -42,7 +44,7 @@
public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
TrafficTreatment treatement, int priority, ApplicationId appId,
- int timeout) {
+ int timeout, boolean permanent) {
if (priority < FlowRule.MIN_PRIORITY) {
throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
@@ -54,6 +56,7 @@
this.treatment = treatement;
this.appId = appId.id();
this.timeout = timeout;
+ this.permanent = permanent;
this.created = System.currentTimeMillis();
this.id = FlowId.valueOf((((long) this.appId) << 48) | (this.hash() & 0x0000ffffffffL));
@@ -67,6 +70,7 @@
this.appId = rule.appId();
this.id = rule.id();
this.timeout = rule.timeout();
+ this.permanent = rule.isPermanent();
this.created = System.currentTimeMillis();
}
@@ -157,4 +161,9 @@
return timeout;
}
+ @Override
+ public boolean isPermanent() {
+ return permanent;
+ }
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
index c63f247..3ac277d 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
@@ -59,8 +59,16 @@
/**
* Returns the timeout for this flow requested by an application.
+ *
* @return integer value of the timeout
*/
int timeout();
+ /**
+ * Returns whether the flow is permanent i.e. does not time out.
+ *
+ * @return true if the flow is permanent, otherwise false
+ */
+ boolean isPermanent();
+
}