laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/36314?usp=email )

Change subject: introduce osmo_stream_cli_get_iofd() API
......................................................................

introduce osmo_stream_cli_get_iofd() API

Using this, a user can obtain the osmo_io_fd, for example in order to
perform configuration like osmo_iofd_set_alloc_info() or
osmo_iofd_set_txqueue_max_length().

Change-Id: Ie19c8294ddb12dfe5e0fd44e047c47e6f9cbd384
---
M include/osmocom/netif/stream.h
M src/stream_cli.c
M src/stream_srv.c
3 files changed, 38 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve




diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 1d97530..61bc1ad 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -109,6 +109,7 @@
 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);
+struct osmo_io_fd *osmo_stream_srv_get_iofd(const struct osmo_stream_srv *srv);
 void osmo_stream_srv_destroy(struct osmo_stream_srv *conn);

 void osmo_stream_srv_set_flush_and_destroy(struct osmo_stream_srv *conn);
@@ -177,6 +178,7 @@
 char *osmo_stream_cli_get_sockname(const struct osmo_stream_cli *cli);
 struct osmo_fd *osmo_stream_cli_get_ofd(struct osmo_stream_cli *cli);
 int osmo_stream_cli_get_fd(const struct osmo_stream_cli *cli);
+struct osmo_io_fd *osmo_stream_cli_get_iofd(const struct osmo_stream_cli *cli);
 void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, int 
(*connect_cb)(struct osmo_stream_cli *cli));
 void osmo_stream_cli_set_disconnect_cb(struct osmo_stream_cli *cli, int 
(*disconnect_cb)(struct osmo_stream_cli *cli));
 void osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, int 
(*read_cb)(struct osmo_stream_cli *cli));
diff --git a/src/stream_cli.c b/src/stream_cli.c
index ca60e25..fa43a22 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -222,6 +222,18 @@
        return -EINVAL;
 }

+/*! Retrieve osmo_io descriptor of the stream client socket.
+ *  This function must not be called on a stream client in legacy osmo_fd mode!
+ *  The iofd is only valid once/after osmo_stream_cli_open() has successfully 
returned.
+ *  \param[in] cli Stream Client of which we want to obtain the file descriptor
+ *  \returns osmo_io_fd of stream client, or NULL if stream not yet opened. */
+struct osmo_io_fd *
+osmo_stream_cli_get_iofd(const struct osmo_stream_cli *cli)
+{
+       OSMO_ASSERT(cli->mode == OSMO_STREAM_MODE_OSMO_IO);
+       return cli->iofd;
+}
+
 static void osmo_stream_cli_read(struct osmo_stream_cli *cli)
 {
        LOGSCLI(cli, LOGL_DEBUG, "message received\n");
diff --git a/src/stream_srv.c b/src/stream_srv.c
index 3220b9e..a02c1c2 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -1037,6 +1037,17 @@
        return -EINVAL;
 }

+/*! Retrieve osmo_io descriptor of the stream server socket.
+ *  This function must not be called on a stream server in legacy osmo_fd mode!
+ *  \param[in] srv Stream Server of which we want to obtain the osmo_io 
descriptor
+ *  \returns osmo_io_fd of stream server. */
+struct osmo_io_fd *
+osmo_stream_srv_get_iofd(const struct osmo_stream_srv *srv)
+{
+       OSMO_ASSERT(srv->mode == OSMO_STREAM_MODE_OSMO_IO);
+       return srv->iofd;
+}
+
 /*! Retrieve the master (Link) from a Stream Server.
  *  \param[in] conn Stream Server of which we want to know the Link
  *  \returns Link through which the given Stream Server is established */

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/36314?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ie19c8294ddb12dfe5e0fd44e047c47e6f9cbd384
Gerrit-Change-Number: 36314
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to