X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dhcpservice%2Fdhcpservice-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fdhcpservice%2FDhcpProvider.java;fp=dhcpservice%2Fdhcpservice-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fdhcpservice%2FDhcpProvider.java;h=7c086c23fe739dbc689f94e7a89638f0fff3b284;hb=a36d06de791b24cfaca4854997794121739a2c59;hp=0000000000000000000000000000000000000000;hpb=3dc16815b89fef0b19107c2155ffb2fd38802c22;p=vpnservice.git diff --git a/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java new file mode 100644 index 00000000..7c086c23 --- /dev/null +++ b/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/vpnservice/dhcpservice/DhcpProvider.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.vpnservice.dhcpservice; + +import org.opendaylight.controller.sal.binding.api.NotificationProviderService; + +import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DhcpProvider implements BindingAwareProvider, AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(DhcpProvider.class); + private IMdsalApiManager mdsalManager; + private DhcpPktHandler dhcpPktHandler; + private Registration packetListener = null; + private NotificationProviderService notificationService; + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("DhcpProvider Session Initiated"); + try { + final DataBroker dataBroker = session.getSALService(DataBroker.class); + dhcpPktHandler = new DhcpPktHandler(dataBroker); + packetListener = notificationService.registerNotificationListener(dhcpPktHandler); + } catch (Exception e) { + LOG.error("Error initializing services", e); + } + } + + + public void setMdsalManager(IMdsalApiManager mdsalManager) { + this.mdsalManager = mdsalManager; + } + + @Override + public void close() throws Exception { + if(packetListener != null) { + packetListener.close(); + } + if(dhcpPktHandler != null) { + dhcpPktHandler.close(); + } + LOG.info("DhcpProvider closed"); + } + + public void setNotificationProviderService(NotificationProviderService notificationServiceDependency) { + this.notificationService = notificationServiceDependency; + } + +}