Added a CODEC for the MRIB to be used by CLI and REST API

Change-Id: Ia57c2862a642f037b2098c4d143822b2d199bc07
diff --git a/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessMembership.java b/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessMembership.java
index 4c08a74..3d7d603 100644
--- a/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessMembership.java
+++ b/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessMembership.java
@@ -31,8 +31,9 @@
      * Process the IGMP Membership report.
      *
      * @param igmp the deserialized IGMP message.
+     * @param receivedFrom the ConnectPoint this message came from.
      */
-    public static void processMembership(IGMP igmp, ConnectPoint recievedFrom) {
+    public static void processMembership(IGMP igmp, ConnectPoint receivedFrom) {
     }
 
 }
diff --git a/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessQuery.java b/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessQuery.java
index 8407bb1..eb25679 100644
--- a/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessQuery.java
+++ b/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPProcessQuery.java
@@ -31,6 +31,7 @@
      * Process the IGMP Membership Query message.
      *
      * @param igmp The deserialzed IGMP message
+     * @param receivedFrom the ConnectPoint this message came from.
      */
     public static void processQuery(IGMP igmp, ConnectPoint receivedFrom) {
     }
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
index ded5a1a..ae5d9e9 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2015 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,11 +18,10 @@
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.onosproject.cli.AbstractShellCommand;
-
 import org.onosproject.mfwd.impl.McastRouteTable;
 
 /**
- * Delete a multicast route.
+ * Deletes a multicast route.
  */
 @Command(scope = "onos", name = "mcast-delete",
         description = "Delete a multicast route flow")
@@ -43,5 +42,4 @@
         McastRouteTable mrib = McastRouteTable.getInstance();
         mrib.removeRoute(sAddr, gAddr);
     }
-}
-
+}
\ No newline at end of file
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastJoinCommand.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastJoinCommand.java
index 3ce2925..7260fde 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastJoinCommand.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastJoinCommand.java
@@ -17,7 +17,6 @@
 

 import org.apache.karaf.shell.commands.Argument;

 import org.apache.karaf.shell.commands.Command;

-import org.onlab.packet.IpPrefix;

 import org.onosproject.cli.AbstractShellCommand;

 

 import org.onosproject.mfwd.impl.McastConnectPoint;

@@ -54,24 +53,7 @@
     @Override

     protected void execute() {

         McastRouteTable mrib = McastRouteTable.getInstance();

-        IpPrefix mcast = IpPrefix.valueOf("224.0.0.0/4");

-        IpPrefix saddr = IpPrefix.valueOf(sAddr);

-        if (mcast.contains(saddr)) {

-            print("Error: the source address " + sAddr + " must be an IPv4 unicast address");

-            return;

-        }

-

-        IpPrefix gaddr = IpPrefix.valueOf(gAddr);

-        if (!mcast.contains(gaddr)) {

-            print("Error: " + gAddr + " must be a multicast group address");

-            return;

-        }

-

         McastRouteBase mr = mrib.addRoute(sAddr, gAddr);

-        if (mr == null) {

-            print("Error: unable to save the multicast state");

-            return;

-        }

 

         // Port format "of:0000000000000023/4"

         if (ingressPort != null) {

diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastShowCommand.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastShowCommand.java
index 215ee84..7fa3a13 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastShowCommand.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastShowCommand.java
@@ -16,21 +16,15 @@
 package org.onosproject.mfwd.cli;
 
 import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onlab.packet.IpPrefix;
 
-import java.util.Map;
-import java.util.Set;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.JsonNode;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.mfwd.impl.McastRouteTable;
+import org.onosproject.mfwd.impl.MRibCodec;
 
 import org.slf4j.Logger;
-import org.onosproject.mfwd.impl.McastRouteTable;
-import org.onosproject.mfwd.impl.McastRouteGroup;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -40,6 +34,7 @@
 public class McastShowCommand extends AbstractShellCommand {
 
     private final Logger log = getLogger(getClass());
+    private static final String MCAST_GROUP = "mcastgroup";
 
     @Override
     protected void execute() {
@@ -52,43 +47,14 @@
     }
 
     public JsonNode json(McastRouteTable mrt) {
-        ObjectMapper mapper = new ObjectMapper();
-        ArrayNode result = mapper.createArrayNode();
-        Map<IpPrefix, McastRouteGroup> mrib4 = mrt.getMrib4();
-        for (McastRouteGroup mg : mrib4.values()) {
-            String sAddr = "";
-            String gAddr = "";
-            String inPort = "";
-            String outPorts = "";
-            if (mg.getSaddr() != null) {
-                sAddr = mg.getSaddr().toString();
-                log.info("Multicast Source: " + sAddr);
-            }
-            if (mg.getGaddr() != null) {
-                gAddr = mg.getGaddr().toString();
-                log.info("Multicast Group: " + gAddr);
-            }
-            if (mg.getIngressPoint() != null) {
-                inPort = mg.getIngressPoint().toString();
-                log.info("Multicast Ingress: " + inPort);
-            }
-            Set<ConnectPoint> eps = mg.getEgressConnectPoints();
-            if (eps != null && !eps.isEmpty()) {
-                outPorts = eps.toString();
-            }
-            result.add(mapper.createObjectNode()
-                                    .put("src", sAddr)
-                                    .put("grp", gAddr)
-                                    .put("inPort", inPort)
-                                    .put("outPorts", outPorts));
-        }
-        return result;
+        ObjectNode pushContent = new MRibCodec().encode(mrt , this);
+        return pushContent;
     }
 
     /**
      * Displays multicast route table entries.
      *
-     * @param mrt route table
+     * @param mrt Mutlicast Route Table
      */
     protected void printMrib4(McastRouteTable mrt) {
         print(mrt.printMcastRouteTable());
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/MRibCodec.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/MRibCodec.java
new file mode 100644
index 0000000..c4f1852
--- /dev/null
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/MRibCodec.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.mfwd.impl;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+
+import org.onlab.packet.IpPrefix;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Optional;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+import org.slf4j.Logger;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Encode and Decode the Multicast Route Table in JSON for CLI and REST commands.
+ */
+public class MRibCodec extends JsonCodec<McastRouteTable> {
+
+    private final Logger log = getLogger(getClass());
+    private static final String SOURCE_ADDRESS = "sourceAddress";
+    private static final String GROUP_ADDRESS = "groupAddress";
+    private static final String INGRESS_POINT = "ingressPoint";
+    private static final String EGRESS_POINT = "egressPoint";
+    private static final String MCASTCONNECTPOINT = "McastConnectPoint";
+    private static final String ELEMENTID = "elementId";
+    private static final String PORTNUMBER = "portNumber";
+    private static final String MCAST_GROUP = "mcastGroup";
+
+    /**
+     * Encode the MRIB into json format.
+     *
+     * @param mcastRouteTable McastRouteTable
+     * @param context CodecContext
+     * @return result ObjectNode
+     */
+    @Override
+    public ObjectNode encode(McastRouteTable mcastRouteTable, CodecContext context) {
+
+        final JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
+        final ObjectNode macastRouteTabNode = nodeFactory.objectNode();
+        ArrayNode mcastGroupNode = context.mapper().createArrayNode();
+        Optional<McastRouteTable> mcastRouteTabOpt = Optional.ofNullable(mcastRouteTable);
+
+        //checking whether the McastRouteTable is present.
+        if (mcastRouteTabOpt.isPresent()) {
+            Map<IpPrefix, McastRouteGroup> mrib4 = mcastRouteTabOpt.get().getMrib4();
+            Optional<Map<IpPrefix, McastRouteGroup>> mrib4Opt = Optional.ofNullable(mrib4);
+
+            //checking whether the mrib4 is present.
+            if (mrib4Opt.isPresent()) {
+
+                for (McastRouteGroup mg : mrib4Opt.get().values()) {
+                    Collection<McastRouteSource> mcastRoute = mg.getSources().values();
+                    Optional<Collection<McastRouteSource>> mcastRouteOpt = Optional.ofNullable(mcastRoute);
+
+                    //checking whether the McastRouteSource List is present.
+                    if (mcastRouteOpt.isPresent()) {
+                        for (McastRouteSource mcastRouteSource : mcastRouteOpt.get()) {
+                            mcastGroupNode.add(createMcastGroupNode(mcastRouteSource, context));
+                        }
+                        macastRouteTabNode.put(MCAST_GROUP, mcastGroupNode);
+                    }
+                }
+            }
+        }
+        return macastRouteTabNode;
+    }
+    /**
+     * Method for creating the McastGroup object node.
+     *
+     * @param mcastRouteSource McastRouteSource
+     */
+    private ObjectNode createMcastGroupNode(McastRouteSource mcastRouteSource, CodecContext context) {
+
+        final ObjectNode mcastGroupNode = context.mapper().createObjectNode();
+        final ObjectNode ingressNode = context.mapper().createObjectNode();
+        final ObjectNode egressNode = context.mapper().createObjectNode();
+        final ArrayNode jsonLabelIds = context.mapper().createArrayNode();
+        final String sAddr = mcastRouteSource.getSaddr().toString();
+        final String gAddr = mcastRouteSource.getGaddr().toString();
+
+        Optional<String> saddrOpt = Optional.ofNullable(sAddr);
+        Optional<String> gaddrOpt = Optional.ofNullable(gAddr);
+
+        //checking source address and group address are present.
+        if (saddrOpt.isPresent() && gaddrOpt.isPresent()) {
+            mcastGroupNode.put(SOURCE_ADDRESS, saddrOpt.get().toString());
+            mcastGroupNode.put(GROUP_ADDRESS, gaddrOpt.get().toString());
+            McastConnectPoint mcastIngCP = mcastRouteSource.getIngressPoint();
+            Optional<McastConnectPoint> mcastIngCPOpt = Optional.ofNullable(mcastIngCP);
+
+            //checking whether the ingress connection point is present.
+            if (mcastIngCPOpt.isPresent()) {
+                ingressNode.put(MCASTCONNECTPOINT, mcastConnectPoint(mcastIngCPOpt.get(), context));
+            }
+
+            mcastGroupNode.put(INGRESS_POINT , ingressNode);
+            Set<McastConnectPoint> mcastEgCPSet = mcastRouteSource.getEgressPoints();
+            Optional<Set<McastConnectPoint>> mcastEgCPOpt = Optional.ofNullable(mcastEgCPSet);
+
+            //checking whether the egress connection points are present.
+            if (mcastEgCPOpt.isPresent()) {
+                for (final McastConnectPoint mcastConnectPoint : mcastEgCPOpt.get()) {
+                    jsonLabelIds.add(mcastConnectPoint(mcastConnectPoint, context));
+                }
+            }
+
+            egressNode.put(MCASTCONNECTPOINT , jsonLabelIds);
+            mcastGroupNode.put(EGRESS_POINT , egressNode);
+        }
+        return mcastGroupNode;
+    }
+
+    /**
+     * Method for creating the McastConnectPoint object node.
+     *
+     * @param mcastConnectPoint McastConnectPoint
+     * @param context CodecContext
+     * @return mcastCpNode ObjectNode
+     */
+    private ObjectNode mcastConnectPoint(McastConnectPoint mcastConnectPoint, CodecContext context) {
+        final ObjectNode mcastCpNode = context.mapper().createObjectNode();
+        mcastCpNode.put(ELEMENTID , mcastConnectPoint.getConnectPoint().elementId().toString());
+        mcastCpNode.put(PORTNUMBER , mcastConnectPoint.getConnectPoint().port().toLong());
+        return mcastCpNode;
+    }
+
+    /**
+     * Decode json format and insert into the flow table.
+     *
+     * @param json ObjectNode
+     * @param context CodecContext
+     * @return mr McastRouteBase
+     */
+    @Override
+    public McastRouteTable decode(ObjectNode json, CodecContext context) {
+
+        String macAddr = null;
+        String portNo = null;
+        String sAddr = json.path(SOURCE_ADDRESS).asText();
+        String gAddr = json.path(GROUP_ADDRESS).asText();
+        JsonNode inPntObjNode = (JsonNode) json.path(INGRESS_POINT);
+        JsonNode egPntArrNode = (JsonNode) json.path(EGRESS_POINT);
+
+        log.debug("sAddr :" + sAddr + " gAddr :" + gAddr + " inPntObjNode :" + inPntObjNode);
+        log.debug("egPntArrNode :" + egPntArrNode.toString());
+
+        McastRouteTable mrib = McastRouteTable.getInstance();
+        McastRouteBase mr = mrib.addRoute(sAddr, gAddr);
+        Optional<JsonNode> inPntOpt = Optional.ofNullable(inPntObjNode);
+
+        if (inPntOpt.isPresent()) {
+
+            JsonNode inMcastCP = inPntOpt.get().path(MCASTCONNECTPOINT);
+            Optional<JsonNode> inCpOpt = Optional.ofNullable(inMcastCP);
+
+            if (inCpOpt.isPresent()) {
+                macAddr = inCpOpt.get().path(ELEMENTID).asText();
+                portNo = inCpOpt.get().path(PORTNUMBER).asText();
+                mr.addIngressPoint(macAddr + "/" + Long.parseLong(portNo));
+            }
+        }
+
+        Optional<JsonNode> egPntOpt = Optional.ofNullable(egPntArrNode);
+
+        if (egPntOpt.isPresent()) {
+            JsonNode egMcastCP = egPntOpt.get().path(MCASTCONNECTPOINT);
+            Optional<JsonNode> egMcCpOpt = Optional.ofNullable(egMcastCP);
+
+            if (egMcCpOpt.isPresent()) {
+                Iterator<JsonNode> egCpIt = egMcCpOpt.get().elements();
+
+                while (egCpIt.hasNext()) {
+
+                    JsonNode egMcastCPObj = egCpIt.next();
+                    Optional<JsonNode> egMcCpObOpt = Optional.ofNullable(egMcastCPObj);
+                    if (egMcCpObOpt.isPresent()) {
+                        macAddr = egMcCpObOpt.get().path(ELEMENTID).asText();
+                        portNo = egMcCpObOpt.get().path(PORTNUMBER).asText();
+                        log.debug("macAddr egPort : " + macAddr + " portNo egPort :" + portNo);
+                        mr.addEgressPoint(macAddr + "/" + Long.parseLong(portNo), McastConnectPoint.JoinSource.STATIC);
+                    }
+                }
+            }
+        }
+       return mrib;
+    }
+}
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
index e78c257..12b7e6d 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
@@ -130,6 +130,7 @@
     /**
      * Find the egress connect point if it exists.
      *
+     * @param cp ConnectPoint to search for
      * @return the connect point when found, null otherwise.
      */
     public McastConnectPoint findEgressConnectPoint(ConnectPoint cp);
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/rest/McastResource.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/rest/McastResource.java
index 878e21d..608e044 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/rest/McastResource.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/rest/McastResource.java
@@ -15,58 +15,135 @@
  */

 package org.onosproject.mfwd.rest;

 

-import com.fasterxml.jackson.databind.JsonNode;

-import com.fasterxml.jackson.databind.ObjectMapper;

-

 import java.io.IOException;

-import java.io.InputStream;

-import java.util.Map;

+import com.fasterxml.jackson.databind.ObjectMapper;

+import com.fasterxml.jackson.databind.node.ObjectNode;

 

+import javax.ws.rs.DefaultValue;

+import javax.ws.rs.QueryParam;

 import javax.ws.rs.Consumes;

 import javax.ws.rs.GET;

 import javax.ws.rs.POST;

+import javax.ws.rs.DELETE;

 import javax.ws.rs.Path;

 import javax.ws.rs.Produces;

 import javax.ws.rs.core.MediaType;

 import javax.ws.rs.core.Response;

 

-import org.onlab.packet.IpPrefix;

-import org.onlab.rest.BaseResource;

-import org.onosproject.mfwd.impl.McastRouteGroup;

+import org.onosproject.mfwd.impl.McastConnectPoint;

 import org.onosproject.mfwd.impl.McastRouteTable;

+import org.onosproject.mfwd.impl.McastRouteBase;

+import org.onosproject.mfwd.impl.MRibCodec;

+import org.onosproject.rest.AbstractWebResource;

+

+import org.slf4j.Logger;

+import static org.slf4j.LoggerFactory.getLogger;

 

 /**

  * Rest API for Multicast Forwarding.

  */

 @Path("mcast")

-public class McastResource extends BaseResource {

+public class McastResource extends AbstractWebResource  {

+

+    private final Logger log = getLogger(getClass());

+    private static final String SOURCE_ADDRESS = "sourceAddress";

+    private static final String GROUP_ADDRESS = "groupAddress";

+    private static final String INGRESS_POINT = "ingressPoint";

+    private static final String EGRESS_POINT = "egressPoint";

+    private static final String MCAST_GROUP = "mcastGroup";

 

     /**

      * Retrieve the multicast route table.

+     *

      * @return the multicast route table.

      * @throws IOException if an error occurs

      */

+    @Path("show")

     @GET

     @Produces(MediaType.APPLICATION_JSON)

     public Response showAll() throws IOException {

-        ObjectMapper mapper = new ObjectMapper();

-        McastRouteTable mcastRouteTable = McastRouteTable.getInstance();

-        Map<IpPrefix, McastRouteGroup> map = mcastRouteTable.getMrib4();

-        return Response.ok(mapper.createObjectNode().toString()).build();

+        McastRouteTable mrt = McastRouteTable.getInstance();

+        ObjectNode pushContent = new MRibCodec().encode(mrt , this);

+        return ok(pushContent.toString()).build();

     }

 

     /**

-     * Static join of a multicast flow.

-     * @param input source, group, ingress connectPoint egress connectPoints

-     * @return status of static join

-     * @throws IOException if an error occurs

+     * Static join a multicast flow.

+     *

+     * @param sAddr source address to join

+     * @param gAddr group address to join

+     * @param ports ingress and egress ConnectPoints to join

+     * @return the Result of the join

+     * @throws IOException if something failed with the join command

      */

+    @Path("/join")

     @POST

     @Consumes(MediaType.APPLICATION_JSON)

-    @Produces(MediaType.APPLICATION_JSON)

-    public Response join(InputStream input) throws IOException {

+    @Produces(MediaType.TEXT_PLAIN)

+    public Response join(@QueryParam("src") String sAddr,

+                    @QueryParam("grp") String gAddr,

+                    @DefaultValue("") @QueryParam("ports") String ports)

+                    throws IOException {

+

         ObjectMapper mapper = new ObjectMapper();

-        JsonNode cfg = mapper.readTree(input);

-        return null;

+        log.debug("Source IP Address: " + sAddr);

+        log.debug("Destination IP Address: " + gAddr);

+        log.debug("Ingress and Egress ports: " + ports);

+

+        String output = "Insertion Faild";

+        if (sAddr != null && gAddr != null && ports != null) {

+

+            String[] portArr = ports.split(",");

+            log.debug("Port Array Length: " + portArr.length);

+            McastRouteTable mrt = McastRouteTable.getInstance();

+            McastRouteBase mr = mrt.addRoute(sAddr, gAddr);

+

+            // Port format "of:0000000000000023/4"

+            log.debug("checking inside outer if: " + portArr.length);

+

+            if (mr != null && portArr != null && portArr.length > 0) {

+

+                String inCP = portArr[0];

+                log.debug("Ingress port provided: " + inCP);

+                mr.addIngressPoint(inCP);

+

+                for (int i = 1; i < portArr.length; i++) {

+                    String egCP = portArr[i];

+                    log.debug("Egress port provided: " + egCP);

+                    mr.addEgressPoint(egCP, McastConnectPoint.JoinSource.STATIC);

+                }

+                mrt.printMcastRouteTable();

+                output = "Successfully Inserted";

+            }

+        } else {

+            output = "Please Insert the rest uri correctly";

+        }

+        return Response.ok(output).build();

+    }

+

+    /**

+     * Delete multicast state.

+     *

+     * @param src address to be deleted

+     * @param grp address to be deleted

+     * @return status of delete if successful

+     */

+    @Path("/delete")

+    @DELETE

+    @Consumes(MediaType.TEXT_PLAIN)

+    @Produces(MediaType.TEXT_PLAIN)

+    public Response removeMcastFlow(@QueryParam("src") String src,

+                    @QueryParam("grp") String grp) {

+

+        String resp = "Failed to delete";

+        log.info("Source IP Address to delete: " + src);

+        log.info("Destination IP Address to delete: " + grp);

+        McastRouteTable mrt = McastRouteTable.getInstance();

+        if (src != null && grp != null) {

+            mrt.removeRoute(src, grp);

+            resp = "Deleted flow for src " + src + " and grp " + grp;

+        }

+

+        return Response.ok(resp).build();

     }

 }