try {
socket = new DatagramSocket(new InetSocketAddress(ourAddress, port));
} catch (SocketException e) {
- e.printStackTrace();
+ LOG.error("Can't initize socket for {}", ourAddress, e);
fail();
}
return socket;
prefix:lisp-sb-impl
</type>
<name>lisp-sb-impl-default</name>
+ <bind-address>0.0.0.0</bind-address>
<rpc-registry>
<type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
sbPlugin.setNotificationPublishService(getNotificationPublishServiceDependency());
sbPlugin.setRpcRegistryDependency(getRpcRegistryDependency());
sbPlugin.setDataBroker(getDataBrokerDependency());
+ sbPlugin.setLispAddress(getBindAddress());
sbPlugin.init();
return sbPlugin;
import static io.netty.buffer.Unpooled.wrappedBuffer;
import com.google.common.base.Preconditions;
+
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.util.concurrent.DefaultThreadFactory;
+
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.concurrent.ThreadFactory;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
private RpcRegistration<OdlLispSbService> sbRpcRegistration;
private NioDatagramChannel xtrChannel;
private LispSouthboundStats statistics = new LispSouthboundStats();
+ private Bootstrap bootstrap = new Bootstrap();
+ private Bootstrap xtrBootstrap = new Bootstrap();
private ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
private EventLoopGroup eventLoopGroup = new NioEventLoopGroup(0, threadFactory);
private DataBroker dataBroker;
lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
+ bootstrap.group(eventLoopGroup);
+ bootstrap.channel(NioDatagramChannel.class);
+ bootstrap.handler(lispSouthboundHandler);
+
+ xtrBootstrap.group(eventLoopGroup);
+ xtrBootstrap.channel(NioDatagramChannel.class);
+ xtrBootstrap.handler(lispXtrSouthboundHandler);
+
start();
startXtr();
private void start() {
try {
- Bootstrap bootstrap = new Bootstrap();
- bootstrap.group(eventLoopGroup);
- bootstrap.channel(NioDatagramChannel.class);
- bootstrap.handler(lispSouthboundHandler);
channel = (NioDatagramChannel) bootstrap.bind(bindingAddress, LispMessage.PORT_NUM).sync().channel();
+ LOG.debug("Binding LISP UDP listening socket to {}:{}", bindingAddress, LispMessage.PORT_NUM);
} catch (Exception e) {
LOG.error("Failed to open main socket ", e);
}
private void startXtr() {
if (listenOnXtrPort) {
try {
- Bootstrap xtrBootstrap = new Bootstrap();
- xtrBootstrap.group(eventLoopGroup);
- xtrBootstrap.channel(NioDatagramChannel.class);
- xtrBootstrap.handler(lispXtrSouthboundHandler);
xtrChannel = (NioDatagramChannel) xtrBootstrap.bind(bindingAddress, xtrPort).sync().channel();
+ LOG.debug("Binding LISP xTR UDP listening socket to {}:{}", bindingAddress, xtrPort);
} catch (Exception e) {
LOG.error("Failed to open xTR socket ", e);
}
private void unloadActions() {
lispSouthboundHandler = null;
lispXtrSouthboundHandler = null;
- bindingAddress = "0.0.0.0";
stop();
stopXtr();
} else {
LOG.debug("Setting LISP binding address to {}", address);
bindingAddress = address;
- try {
- restart();
- restartXtr();
- } catch (Exception e) {
- LOG.error("Failed to set LISP binding address: ", e);
+ if (channel != null) {
+ try {
+ restart();
+ restartXtr();
+ } catch (Exception e) {
+ LOG.error("Failed to set LISP binding address: ", e);
+ }
}
}
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Contextream, Inc. 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.yang.gen.v1.lispconfig.rev131107;
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-
-public class LispConfigContextSetterImpl implements Closeable {
-
- public void updateContext(LispConfigModule module) {
- BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- IConfigLispSouthboundPlugin service = (IConfigLispSouthboundPlugin) bundleContext
- .getService(bundleContext.getServiceReference(IConfigLispSouthboundPlugin.class.getName()));
- service.setLispAddress(module.getBindAddress());
- }
-
- @Override
- public void close() throws IOException {
- }
-}
+++ /dev/null
-package org.opendaylight.yang.gen.v1.lispconfig.rev131107;
-
-import java.net.Inet4Address;
-import java.net.UnknownHostException;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-
-/**
-* Actual state of lisp configuration.
-*/
-public class LispConfigModule extends org.opendaylight.yang.gen.v1.lispconfig.rev131107.AbstractLispConfigModule {
- public LispConfigModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public LispConfigModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.lispconfig.rev131107.LispConfigModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public void customValidation() {
- super.customValidation();
- try {
- Inet4Address.getByName(getBindAddress());
- } catch (UnknownHostException e) {
- throw new JmxAttributeValidationException("LISP bind address is not a valid ipv4 address: " + getBindAddress(), bindAddressJmxAttribute);
- }
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- LispConfigContextSetterImpl setter = new LispConfigContextSetterImpl();
- setter.updateContext(this);
- return setter;
- }
-
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: config-lisp yang module local name: lispconfig
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Sep 24 15:15:47 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.lispconfig.rev131107;
-public class LispConfigModuleFactory extends org.opendaylight.yang.gen.v1.lispconfig.rev131107.AbstractLispConfigModuleFactory {
-
-}
+++ /dev/null
-module config-lisp {
- yang-version 1;
- namespace "lispconfig";
- prefix "lispconfig";
-
- import config { prefix config; revision-date 2013-04-05; }
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
- organization "Contextream, Inc.";
-
- description
- "This module contains the base YANG definitions for lisp configuration.";
-
- revision "2013-11-07" {
- description
- "Initial revision.";
- }
-
- identity lispconfig {
- description
- "Actual state of lisp configuration.";
- base config:module-type;
- config:java-name-prefix LispConfig;
- }
-
- identity lispconfig-rpc;
-
- augment "/config:modules/config:module/config:configuration" {
- case lispconfig {
- when "/config:modules/config:module/config:type = 'lispconfig'";
-
- leaf bind-address {
- type string;
- mandatory true;
- }
- }
- }
-
-
- augment "/config:modules/config:module/config:state" {
- case lispconfig {
- when "/config:modules/config:module/config:type = 'lispconfig'";
-
- rpcx:rpc-context-instance "lispconfig-rpc";
-
- }
- }
-
- //rpc rpcmethodexample {
- // input {
- // uses rpcx:rpc-context-ref {
- // refine context-instance {
- // rpcx:rpc-context-instance lispconfig-rpc;
- // }
- // }
- // }
- // }
-
-}
-
module odl-lisp-sb-impl {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl";
- prefix "lisp-sb-impl";
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl";
+ prefix "lisp-sb-impl";
- import config { prefix config; revision-date 2013-04-05; }
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
- import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
- import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
- import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
- import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
+ import config { prefix config; revision-date 2013-04-05; }
+ import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+ import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
+ import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
+ import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
- description
- "This module contains the base YANG definitions for
- mappingservice southbound plugin implementation.";
+ description
+ "This module contains the base YANG definitions for
+ mappingservice southbound plugin implementation.";
- revision "2015-05-17" {
- description
- "Initial revision.";
- }
+ revision "2015-05-17" {
+ description
+ "Initial revision.";
+ }
- identity lisp-sb-impl {
- base config:module-type;
- config:provided-service lisp-sb:lisp-sb;
- config:java-name-prefix LfmMappingServiceSb;
- }
+ identity lisp-sb-impl {
+ base config:module-type;
+ config:provided-service lisp-sb:lisp-sb;
+ config:java-name-prefix LfmMappingServiceSb;
+ }
- // Augments the 'configuration' choice node under modules/module.
- augment "/config:modules/config:module/config:configuration" {
- case lisp-sb-impl {
- when "/config:modules/config:module/config:type = 'lisp-sb-impl'";
+ // Augments the 'configuration' choice node under modules/module.
+ augment "/config:modules/config:module/config:configuration" {
+ case lisp-sb-impl {
+ when "/config:modules/config:module/config:type = 'lisp-sb-impl'";
- container notification-publish-service {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity sal-broker:binding-new-notification-publish-service;
- }
- }
- }
+ container notification-publish-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal-broker:binding-new-notification-publish-service;
+ }
+ }
+ }
- container rpc-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-rpc-registry;
- }
- }
- }
+ container rpc-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-rpc-registry;
+ }
+ }
+ }
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-async-data-broker;
+ }
+ }
+ }
+ leaf bind-address {
+ type string;
+ mandatory true;
+ }
+
+ }
}
- }
}