import java.nio.ByteBuffer;
import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.southbound.lisp.ILispSouthboundService;
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundService;
import org.opendaylight.lispflowmapping.southbound.lisp.LispXtrSouthboundService;
import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.LispProtoService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev150820.transportaddress.TransportAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transportaddress.TransportAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.LispSbService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private LispIoThread xtrThread;
private LispSouthboundService lispSouthboundService;
private LispXtrSouthboundService lispXtrSouthboundService;
- private NotificationProviderService notificationService;
+ private NotificationPublishService notificationPublishService;
private RpcProviderRegistry rpcRegistry;
private BindingAwareBroker broker;
private volatile DatagramSocket socket = null;
private volatile String bindingAddress = null;
private volatile int xtrPort = LispMessage.XTR_PORT_NUM;
private volatile boolean listenOnXtrPort = false;
- private BindingAwareBroker.RpcRegistration<LispProtoService> controlPlaneRpc;
+ private BindingAwareBroker.RpcRegistration<LispSbService> sbRpcRegistration;
private DatagramSocket xtrSocket;
+ private LispSouthboundStats statistics = new LispSouthboundStats();
public void init() {
- LOG.info("LISP (RFC6830) Mapping Service is up!");
- final LfmControlPlaneRpc lfmCpRpc = new LfmControlPlaneRpc(this);
+ LOG.info("LISP (RFC6830) southbound plugin is initializing...");
+ final LispSouthboundRPC sbRpcHandler = new LispSouthboundRPC(this);
- controlPlaneRpc = rpcRegistry.addRpcImplementation(LispProtoService.class, lfmCpRpc);
+ sbRpcRegistration = rpcRegistry.addRpcImplementation(LispSbService.class, sbRpcHandler);
broker.registerProvider(this);
synchronized (startLock) {
- lispSouthboundService = new LispSouthboundService();
+ lispSouthboundService = new LispSouthboundService(this);
lispXtrSouthboundService = new LispXtrSouthboundService();
- lispSouthboundService.setNotificationProvider(this.notificationService);
- lispXtrSouthboundService.setNotificationProvider(this.notificationService);
- LOG.trace("Provider Session initialized");
+ lispSouthboundService.setNotificationProvider(this.notificationPublishService);
+ lispXtrSouthboundService.setNotificationProvider(this.notificationPublishService);
if (bindingAddress == null) {
setLispAddress("0.0.0.0");
}
- LOG.info("LISP (RFC6830) Mapping Service is up!");
+ LOG.info("LISP (RFC6830) southbound plugin is up!");
}
}
- public void setNotificationProviderService(NotificationProviderService notificationService) {
- this.notificationService = notificationService;
+ public void setNotificationPublishService(NotificationPublishService notificationService) {
+ this.notificationPublishService = notificationService;
}
public void setRpcRegistryDependency(RpcProviderRegistry rpcRegistry) {
lispThread = null;
xtrThread = null;
bindingAddress = null;
- LOG.info("LISP (RFC6830) Mapping Service is down!");
+ LOG.info("LISP (RFC6830) southbound plugin is down!");
try {
Thread.sleep(1100);
} catch (InterruptedException e) {
int lispReceiveTimeout = 1000;
- LOG.info("LISP (RFC6830) Mapping Service is running and listening on address: " + bindingAddress
+ LOG.info("LISP (RFC6830) southbound plugin is running and listening on address: " + bindingAddress
+ " port: " + threadSocket.getLocalPort());
try {
((address >> 0) & 0xff);
}
- public String getHelp() {
- StringBuffer help = new StringBuffer();
- help.append("---LISP Southbound Plugin---\n");
- return help.toString();
- }
-
private void startIOThread() {
if (socket != null) {
while (!socket.isClosed()) {
socket = new DatagramSocket(new InetSocketAddress(bindingAddress, LispMessage.PORT_NUM));
lispThread = new LispIoThread(socket, lispSouthboundService);
lispThread.start();
- LOG.info("LISP (RFC6830) Mapping Service Southbound Plugin is up!");
+ LOG.info("LISP (RFC6830) southbound plugin is listening for control packets!");
if (listenOnXtrPort) {
restartXtrThread();
}
xtrSocket = new DatagramSocket(new InetSocketAddress(bindingAddress, xtrPort));
xtrThread = new LispIoThread(xtrSocket, lispXtrSouthboundService);
xtrThread.start();
- LOG.info("xTR Southbound Plugin is up!");
+ LOG.info("xTR southbound plugin is up!");
} catch (SocketException e) {
LOG.warn("failed to start xtr thread: {}", ExceptionUtils.getStackTrace(e));
}
}
- public void handleSerializedLispBuffer(TransportAddress address, ByteBuffer outBuffer, String packetType) {
+ public void handleSerializedLispBuffer(TransportAddress address, ByteBuffer outBuffer, MessageType packetType) {
DatagramPacket packet = new DatagramPacket(outBuffer.array(), outBuffer.limit());
packet.setPort(address.getPort().getValue());
InetAddress ip = InetAddresses.forString(new String(address.getIpAddress().getValue()));
LOG.trace("Sending " + packetType + " on port " + address.getPort().getValue() + " to address: " + ip);
}
socket.send(packet);
+ this.statistics.incrementTx(packetType.getIntValue());
} catch (IOException e) {
LOG.warn("Failed to send " + packetType, e);
+ this.statistics.incrementTxErrors();
}
}
+ public LispSouthboundStats getStats() {
+ return statistics;
+ }
+
public void setLispAddress(String address) {
synchronized (startLock) {
if (bindingAddress != null && bindingAddress.equals(address)) {
@Override
public void close() throws Exception {
unloadActions();
- controlPlaneRpc.close();
+ sbRpcRegistration.close();
}
@Override