add route alert switch, otherwith the period query may be discarded

Change-Id: I2047a5712b52388e270e992401ce6c3d77eb71f3
diff --git a/src/main/java/org/opencord/igmp/IgmpSnoop.java b/src/main/java/org/opencord/igmp/IgmpSnoop.java
index c5bae42..fed8a30 100644
--- a/src/main/java/org/opencord/igmp/IgmpSnoop.java
+++ b/src/main/java/org/opencord/igmp/IgmpSnoop.java
@@ -96,7 +96,7 @@
 
     private static final String DEST_MAC = "01:00:5E:00:00:01";
     private static final String DEST_IP = "224.0.0.1";
-
+    private static final byte[] ROUTE_ALERT_BYTES = {(byte) 0x94, (byte) 0x04, (byte) 0x00, (byte) 0x00};
     private static final int DEFAULT_QUERY_PERIOD_SECS = 60;
     private static final byte DEFAULT_IGMP_RESP_CODE = 100;
 
@@ -112,6 +112,10 @@
             label = "Maximum time allowed before sending a responding report")
     private byte maxRespCode = DEFAULT_IGMP_RESP_CODE;
 
+    @Property(name = "routeAlert", boolValue = false,
+            label = "add Route Alert in igmp query header or not")
+    private boolean routerAlert = false;
+
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected FlowObjectiveService flowObjectiveService;
 
@@ -247,6 +251,7 @@
         // TODO read multicastAddress from config
         String strQueryPeriod = Tools.get(properties, "queryPeriod");
         String strResponseCode = Tools.get(properties, "maxRespCode");
+        String strRouteAlert = Tools.get(properties, "routeAlert");
         try {
             byte newMaxRespCode = Byte.parseByte(strResponseCode);
             if (maxRespCode != newMaxRespCode) {
@@ -260,6 +265,12 @@
                 restartQueryTask();
             }
 
+            boolean newRouteAlert = Boolean.parseBoolean(strRouteAlert);
+            if (newRouteAlert != routerAlert) {
+                routerAlert = newRouteAlert;
+                queryPacket = buildQueryPacket();
+            }
+
         } catch (NumberFormatException e) {
             log.warn("Error parsing config input", e);
         }
@@ -388,6 +399,10 @@
         ip.setTtl((byte) 1);
         ip.setPayload(igmp);
 
+        if (routerAlert) {
+            ip.setOptions(ROUTE_ALERT_BYTES);
+        }
+
         Ethernet eth = new Ethernet();
         eth.setDestinationMACAddress(DEST_MAC);
         eth.setSourceMACAddress("DE:AD:BE:EF:BA:11");
@@ -575,4 +590,4 @@
                 .filter(p -> p.isEnabled())
                 .forEach(p -> processFilterObjective((DeviceId) p.element().id(), p, false));
     }
-}
+}
\ No newline at end of file