adding igmp rule
Change-Id: I0eaeb55861eb3f9f273a3b67fa7b0eaa98b0210e
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/OLTPipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/OLTPipeline.java
index c360c90..79d2b0a 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/OLTPipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/OLTPipeline.java
@@ -16,12 +16,15 @@
package org.onosproject.driver.pipeline;
import org.onlab.osgi.ServiceDirectory;
+import org.onlab.packet.Ethernet;
+import org.onosproject.core.ApplicationId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.Pipeliner;
import org.onosproject.net.behaviour.PipelinerContext;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleOperations;
@@ -49,12 +52,44 @@
private FlowRuleService flowRuleService;
private DeviceId deviceId;
+ private boolean done = false;
+
@Override
public void init(DeviceId deviceId, PipelinerContext context) {
this.serviceDirectory = context.directory();
this.deviceId = deviceId;
flowRuleService = serviceDirectory.get(FlowRuleService.class);
+
+ }
+
+ private boolean installIGMPRule(ApplicationId appId, boolean done) {
+ if (done) {
+ return done;
+ }
+ TrafficSelector selector = DefaultTrafficSelector.builder()
+ .matchInPort(PortNumber.portNumber(1))
+ .matchEthType(Ethernet.TYPE_IPV4)
+ .matchIPProtocol((byte) 2).build();
+
+ TrafficTreatment treatment = DefaultTrafficTreatment.builder()
+ .punt().build();
+
+ FlowRule rule = DefaultFlowRule.builder()
+ .forDevice(deviceId)
+ .fromApp(appId)
+ .withTreatment(treatment)
+ .withSelector(selector)
+ .makePermanent()
+ .withPriority(0)
+ .build();
+
+ FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder();
+
+ flowRuleService.apply(flowBuilder.add(rule).build());
+
+ return true;
+
}
@Override
@@ -64,6 +99,7 @@
@Override
public void forward(ForwardingObjective fwd) {
+ done = installIGMPRule(fwd.appId(), done);
FlowRuleOperations.Builder flowBuilder = FlowRuleOperations.builder();
if (fwd.flag() != ForwardingObjective.Flag.VERSATILE) {