Bug 1544 - Explicit LLDP flow to punt whole LLDP packets to the controller
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / OpenflowPluginProvider.java
index 24fa9084ee9b7af299d9c71c794835d8ee3c56a5..2ec7fb1458656a1d0d4bf3315371cd6a9d1f57cb 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
@@ -19,11 +21,16 @@ import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrat
 import org.opendaylight.openflowplugin.openflow.md.core.MDController;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManager;
+import org.opendaylight.openflowplugin.openflow.md.lldp.LLDPPAcketPuntEnforcer;
 import org.opendaylight.openflowplugin.statistics.MessageCountCommandProvider;
 import org.opendaylight.openflowplugin.statistics.MessageCountDumper;
 import org.opendaylight.openflowplugin.statistics.MessageObservatory;
 import org.opendaylight.openflowplugin.statistics.MessageSpyCounterImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -91,6 +98,14 @@ public class OpenflowPluginProvider implements BindingAwareProvider, AutoCloseab
         LOG.debug("onSessionInitiated");
         registrationManager = new SalRegistrationManager();
         registrationManager.onSessionInitiated(session);
+        //TODO : LLDPPAcketPuntEnforcer should be instantiated and registered in separate module driven by config subsystem
+        InstanceIdentifier path = InstanceIdentifier.create(Nodes.class).child(Node.class);
+        registrationManager.getSessionManager().getDataBroker().registerDataChangeListener(
+                LogicalDatastoreType.OPERATIONAL,
+                path,
+                new LLDPPAcketPuntEnforcer(
+                        session.<SalFlowService>getRpcService(SalFlowService.class)),
+                AsyncDataBroker.DataChangeScope.BASE);
         mdController = new MDController();
         mdController.setSwitchConnectionProviders(switchConnectionProviders);
         mdController.setMessageSpyCounter(messageCountProvider);