New function rconn_get_ip().
authorBen Pfaff <blp@nicira.com>
Wed, 16 Jul 2008 20:22:30 +0000 (13:22 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 18 Jul 2008 20:23:23 +0000 (13:23 -0700)
include/rconn.h
lib/rconn.c

index 17fcef8..6735686 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "queue.h"
 #include <stdbool.h>
+#include <stdint.h>
 #include <time.h>
 
 /* A wrapper around vconn that provides queuing and optionally reliability.
@@ -72,4 +73,6 @@ bool rconn_is_alive(const struct rconn *);
 bool rconn_is_connected(const struct rconn *);
 int rconn_disconnected_duration(const struct rconn *);
 
+uint32_t rconn_get_ip(const struct rconn *);
+
 #endif /* rconn.h */
index 46fd51d..a6613ff 100644 (file)
@@ -324,6 +324,14 @@ rconn_disconnected_duration(const struct rconn *rconn)
 {
     return rconn_is_connected(rconn) ? 0 : time(0) - rconn->last_connected;
 }
+
+/* Returns the IP address of the peer, or 0 if the peer is not connected over
+ * an IP-based protocol or if its IP address is not known. */
+uint32_t
+rconn_get_ip(const struct rconn *rconn) 
+{
+    return rconn->vconn ? vconn_get_ip(rconn->vconn) : 0;
+}
 \f
 static struct rconn *
 create_rconn(const char *name, int txq_limit, int probe_interval,