diff options
author | Harald Welte <laforge@osmocom.org> | 2024-03-16 09:34:02 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2024-03-17 17:41:22 +0000 |
commit | 34a657d1e1fd29241a1b910fb3ec8d1d8a0b03ff (patch) | |
tree | 3aa05f352d0a87484cc8016423b77ab93e55a16b | |
parent | 9ea35aea67ec0b4356d8e3ca071a94454d900f02 (diff) |
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
-rw-r--r-- | include/osmocom/netif/stream.h | 2 | ||||
-rw-r--r-- | src/stream_cli.c | 12 | ||||
-rw-r--r-- | src/stream_srv.c | 11 |
3 files changed, 25 insertions, 0 deletions
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 @@ struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv * 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 @@ void *osmo_stream_cli_get_data(struct osmo_stream_cli *cli); 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 @@ osmo_stream_cli_get_fd(const struct osmo_stream_cli *cli) 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 @@ osmo_stream_srv_get_fd(const struct osmo_stream_srv *conn) 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 */ |