INT full rule population

Change-Id: Ica854f1cc0b3eb9b3e8b16eafed5b515b0f17aad
diff --git a/apps/int-demo/src/main/java/org/onosproject/intdemo/IntDemoApp.java b/apps/int-demo/src/main/java/org/onosproject/intdemo/IntDemoApp.java
index e883fdc..a93c414 100644
--- a/apps/int-demo/src/main/java/org/onosproject/intdemo/IntDemoApp.java
+++ b/apps/int-demo/src/main/java/org/onosproject/intdemo/IntDemoApp.java
@@ -64,7 +64,7 @@
 public class IntDemoApp {
 
     private static final int DEFAULT_TEID = 0;
-    protected final Logger log = getLogger(getClass());
+    private final Logger log = getLogger(getClass());
 
     private static final String SPGW_INT_PIPECONF_KEYWORD = "spgw-int";
     private static final String SPGW_DEVICE_KEYWORD = "leaf2";
@@ -74,20 +74,12 @@
             "160.0.2.1", "160.0.2.2", "160.0.2.3", "160.0.2.4", "160.0.2.5");
 
     private static final Map<String, Integer> SWITCH_ID_MAP = new ImmutableMap.Builder<String, Integer>()
-            .put("leaf1", 0)
-            .put("leaf2", 1)
+            .put("leaf1", 100)
+            .put("leaf2", 200)
             .build();
-
-    private static final PiTableId TBL_ID_INT_INST = PiTableId
-            .of("int_egress.int_metadata_insert.int_inst_0003");
     private static final PiTableId TBL_ID_INT_PREP = PiTableId
             .of("int_egress.int_prep");
 
-    private static final PiMatchFieldId FM_ID_INST_MASK = PiMatchFieldId
-            .of("hdr.int_header.instruction_mask_0003");
-
-    private static final PiActionId ACT_ID_INST_ALL = PiActionId
-            .of("int_egress.int_metadata_insert.int_set_header_0003_i15");
     private static final PiActionId ACT_ID_INT_TRANSIT = PiActionId
             .of("int_egress.int_transit");
 
@@ -166,28 +158,38 @@
                                         PiAction.builder()
                                                 .withId(ACT_ID_INT_TRANSIT)
                                                 .withParameter(new PiActionParam(
-                                                        ACTP_ID_SWITCH_ID, copyFrom(0)))
+                                                        ACTP_ID_SWITCH_ID, copyFrom(switchId.get())))
                                                 .build())
                                 .build())
                 .build();
 
-        FlowRule intIntrRule = flowRuleBuilder(deviceId, TBL_ID_INT_INST)
-                .withSelector(
-                        DefaultTrafficSelector.builder()
-                                .matchPi(
-                                        PiCriterion.builder()
-                                                .matchExact(FM_ID_INST_MASK, (byte) 0x0F)
-                                                .build())
-                                .build())
-                .withTreatment(
-                        DefaultTrafficTreatment.builder()
-                                .piTableAction(PiAction.builder()
-                                                       .withId(ACT_ID_INST_ALL)
-                                                       .build())
-                                .build())
-                .build();
+        for (String instMask : ImmutableList.of("0003", "0407")) {
+            for (int i = 0; i < 16; i++) {
+                PiTableId tableId = PiTableId
+                        .of("int_egress.int_metadata_insert.int_inst_" + instMask);
+                PiMatchFieldId fmId = PiMatchFieldId
+                        .of("hdr.int_header.instruction_mask_" + instMask);
+                PiActionId actionId = PiActionId
+                        .of("int_egress.int_metadata_insert.int_set_header_" + instMask + "_i" + String.valueOf(i));
+                FlowRule intIntrRule = flowRuleBuilder(deviceId, tableId)
+                        .withSelector(
+                                DefaultTrafficSelector.builder()
+                                        .matchPi(
+                                                PiCriterion.builder()
+                                                        .matchExact(fmId, (byte) i)
+                                                        .build())
+                                        .build())
+                        .withTreatment(
+                                DefaultTrafficTreatment.builder()
+                                        .piTableAction(PiAction.builder()
+                                                               .withId(actionId)
+                                                               .build())
+                                        .build())
+                        .build();
 
-        flowRuleService.applyFlowRules(intPrepRule, intIntrRule);
+                flowRuleService.applyFlowRules(intPrepRule, intIntrRule);
+            }
+        }
     }
 
     private void confSpgw(DeviceId deviceId) {