pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/35286?usp=email )
Change subject: stream_cli: Introduce API osmo_stream_srv_get_sockname() ......................................................................
stream_cli: Introduce API osmo_stream_srv_get_sockname()
Similar to what osmo_stream_srv_link and osmo_stream_cli already have.
Change-Id: I171befd1fdf40c3cbb3fc7e4c3eedf82128b0712 Related: SYS#5580 --- M include/osmocom/netif/stream.h M src/stream_srv.c 2 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/86/35286/1
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 681f9ec..2e6aa97 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -64,6 +64,7 @@ void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, int (*closed_cb)(struct osmo_stream_srv *conn)); void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn); struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn); +const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn); struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv); int osmo_stream_srv_get_fd(const struct osmo_stream_srv *srv); void osmo_stream_srv_destroy(struct osmo_stream_srv *conn); diff --git a/src/stream_srv.c b/src/stream_srv.c index f5a0b42..0dca10a 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -836,6 +836,19 @@ return conn->data; }
+/*! \brief Get the stream server socket description. + * \param[in] cli Stream Server to examine + * \returns Socket description or NULL in case of error */ +const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn) +{ + static char buf[OSMO_STREAM_MAX_ADDRS * OSMO_SOCK_NAME_MAXLEN]; + + osmo_sock_multiaddr_get_name_buf(buf, sizeof(buf), + osmo_stream_srv_get_fd(conn), conn->srv->proto); + + return buf; +} + /*! \brief Get Osmocom File Descriptor of the stream server * \param[in] conn Stream Server * \returns Pointer to \ref osmo_fd */