Added a get method for InetSocketAddress of a remote OF switch 15/9615/3
authorMartin Sunal <msunal@cisco.com>
Sat, 2 Aug 2014 17:24:09 +0000 (19:24 +0200)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 27 Aug 2014 14:00:34 +0000 (14:00 +0000)
Signed-off-by: Martin Sunal <msunal@cisco.com>
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java

index cb3edd1ff78c7092f5c2a9ee86c5b7e060f3e54a..d9d63228a6a9ed79605629edcb5dbc74a1cfec8a 100644 (file)
@@ -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
      */
index 6fd5fd7f55949d68c41316f5c935658955b5d203..44595d7c2f1d85113cfba53e135deeadc8aeb95f 100644 (file)
@@ -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<RpcResponseKey, ResponseExpectedRpcListener<?>> 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();
+    }
 }