From: Ben Pfaff Date: Wed, 16 Jul 2008 20:22:30 +0000 (-0700) Subject: New function rconn_get_ip(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4532f9cdfb2bec50f413164b5cb5e7fdbd7d22be;p=openvswitch New function rconn_get_ip(). --- diff --git a/include/rconn.h b/include/rconn.h index 17fcef82..67356862 100644 --- a/include/rconn.h +++ b/include/rconn.h @@ -36,6 +36,7 @@ #include "queue.h" #include +#include #include /* 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 */ diff --git a/lib/rconn.c b/lib/rconn.c index 46fd51df..a6613ffe 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -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; +} static struct rconn * create_rconn(const char *name, int txq_limit, int probe_interval,