adding group id to flowrules
Change-Id: Idb660d98f145b1645e9781fab79fbfb81bdce775
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 f31f3c3..deef14e 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
@@ -40,6 +40,7 @@
private final int timeout;
private final boolean permanent;
+ private final short groupId;
public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
@@ -54,12 +55,19 @@
this.created = System.currentTimeMillis();
this.appId = (short) (flowId >>> 48);
+ this.groupId = (short) ((flowId >>> 32) & 0xFFFF);
this.id = FlowId.valueOf(flowId);
}
public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority, ApplicationId appId,
- int timeout, boolean permanent) {
+ TrafficTreatment treatment, int priority, ApplicationId appId,
+ int timeout, boolean permanent) {
+ this(deviceId, selector, treatment, priority, appId, (short) 0, timeout, permanent);
+ }
+
+ public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+ TrafficTreatment treatment, int priority, ApplicationId appId,
+ short groupId, int timeout, boolean permanent) {
if (priority < FlowRule.MIN_PRIORITY) {
throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
@@ -70,11 +78,17 @@
this.selector = selector;
this.treatment = treatment;
this.appId = appId.id();
+ this.groupId = groupId;
this.timeout = timeout;
this.permanent = permanent;
this.created = System.currentTimeMillis();
- this.id = FlowId.valueOf((((long) this.appId) << 48) | (this.hash() & 0x0000ffffffffL));
+ /*
+ * id consists of the following.
+ * | appId (16 bits) | groupId (16 bits) | flowId (32 bits) |
+ */
+ this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId) << 32)
+ | (this.hash() & 0xffffffffL));
}
public DefaultFlowRule(FlowRule rule) {
@@ -83,6 +97,7 @@
this.selector = rule.selector();
this.treatment = rule.treatment();
this.appId = rule.appId();
+ this.groupId = rule.groupId();
this.id = rule.id();
this.timeout = rule.timeout();
this.permanent = rule.isPermanent();
@@ -102,6 +117,11 @@
}
@Override
+ public short groupId() {
+ return groupId;
+ }
+
+ @Override
public int priority() {
return priority;
}
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 f082db4..8ea39e0 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
@@ -42,6 +42,13 @@
short appId();
/**
+ * Returns the group id of this flow.
+ *
+ * @return an groupId
+ */
+ short groupId();
+
+ /**
* Returns the flow rule priority given in natural order; higher numbers
* mean higher priorities.
*
diff --git a/core/api/src/test/java/org/onlab/onos/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onlab/onos/net/intent/IntentTestsMocks.java
index 65df6b2..90e9bec 100644
--- a/core/api/src/test/java/org/onlab/onos/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onlab/onos/net/intent/IntentTestsMocks.java
@@ -297,6 +297,11 @@
}
@Override
+ public short groupId() {
+ return 0;
+ }
+
+ @Override
public int priority() {
return priority;
}