Add a new method sendMsg(OFMessage msg, TableType type) in OpenFlowSwitch interface to support multiple-table aware FlowRuleService.
  Other changes are caused due to the new method.
Add type() in FlowRule interface to determine the table in which the flow rule need to be set.

Change-Id: I6518a01f4a5fba23f09f70b619f3844b5e33ce8f
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index c83c156..e555794 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -40,6 +40,8 @@
     private final boolean permanent;
     private final GroupId groupId;
 
+    private final Type type;
+
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
             TrafficTreatment treatment, int priority, long flowId,
@@ -55,12 +57,42 @@
         this.appId = (short) (flowId >>> 48);
         this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
         this.id = FlowId.valueOf(flowId);
+        this.type = Type.DEFAULT;
     }
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
                            TrafficTreatment treatment, int priority, ApplicationId appId,
                            int timeout, boolean permanent) {
-        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0), timeout, permanent);
+        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0),
+                timeout, permanent);
+    }
+
+    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+                           TrafficTreatment treatment, int priority, ApplicationId appId,
+                           int timeout, boolean permanent, Type type) {
+
+        if (priority < FlowRule.MIN_PRIORITY) {
+            throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
+        }
+
+        this.deviceId = deviceId;
+        this.priority = priority;
+        this.selector = selector;
+        this.treatment = treatment;
+        this.appId = appId.id();
+        this.groupId = new DefaultGroupId(0);
+        this.timeout = timeout;
+        this.permanent = permanent;
+        this.created = System.currentTimeMillis();
+        this.type = type;
+
+        /*
+         * 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.id()) << 32)
+                | (this.hash() & 0xffffffffL));
+
     }
 
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
@@ -80,6 +112,7 @@
         this.timeout = timeout;
         this.permanent = permanent;
         this.created = System.currentTimeMillis();
+        this.type = Type.DEFAULT;
 
         /*
          * id consists of the following.
@@ -100,10 +133,10 @@
         this.timeout = rule.timeout();
         this.permanent = rule.isPermanent();
         this.created = System.currentTimeMillis();
+        this.type = rule.type();
 
     }
 
-
     @Override
     public FlowId id() {
         return id;
@@ -198,4 +231,9 @@
         return permanent;
     }
 
+    @Override
+    public Type type() {
+        return type;
+    }
+
 }