From: Martin Sunal Date: Sat, 2 Aug 2014 17:24:09 +0000 (+0200) Subject: Added a get method for InetSocketAddress of a remote OF switch X-Git-Tag: release/helium~12 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F9615%2F3;p=openflowjava.git Added a get method for InetSocketAddress of a remote OF switch Signed-off-by: Martin Sunal --- diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index cb3edd1f..d9d63228 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.api.connection; +import java.net.InetSocketAddress; import java.util.concurrent.Future; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; @@ -32,6 +33,10 @@ public interface ConnectionAdapter extends OpenflowProtocolService { */ public boolean isAlive(); + /** + * @return address of the remote end - address of a switch if connected + */ + public InetSocketAddress getRemoteAddress(); /** * @param messageListener here will be pushed all messages from switch */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 6fd5fd7f..44595d7c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -9,11 +9,11 @@ package org.opendaylight.openflowjava.protocol.impl.connection; -import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.socket.SocketChannel; import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; @@ -111,7 +111,7 @@ public class ConnectionAdapterImpl implements ConnectionFacade { private final Cache> responseCache; private final ChannelOutboundQueue output; - private final Channel channel; + private final SocketChannel channel; private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; @@ -468,4 +468,9 @@ public class ConnectionAdapterImpl implements ConnectionFacade { final ConnectionReadyListener connectionReadyListener) { this.connectionReadyListener = connectionReadyListener; } + + @Override + public InetSocketAddress getRemoteAddress() { + return channel.remoteAddress(); + } }