aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2024-03-12 11:55:50 +0100
committerpespin <pespin@sysmocom.de>2024-03-13 11:57:47 +0000
commit36eb157ed63ae3490ea60b603ebc8992cd8f4d4f (patch)
tree8d8bcaa8a2f3dd426658c3761e36ccfe744248ad
parentc17dc5f55926ef88acb096f6af4356ff4b9dfb3f (diff)
stream: Add osmo_stream_*_get_name() APIs
This allows users to retrieve a previously set name. Change-Id: If5054d3c207f8f5d58a448f1e58266ad9c4386dd
-rw-r--r--TODO-RELEASE1
-rw-r--r--include/osmocom/netif/stream.h3
-rw-r--r--src/stream_cli.c9
-rw-r--r--src/stream_srv.c18
4 files changed, 31 insertions, 0 deletions
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 6642459..111f0c5 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -13,3 +13,4 @@ libosmocore >1.9.0 use OSMO_IO_FD_MODE_RECVMSG_SENDMSG
libosmocore >1.9.0 use osmo_iofd_get_ioops()
libosmo-netif added osmo_stream_srv_get_sockname()
libosmo-netif update-dependency libosmocore > 1.9.0 required for I89eb519b22d21011d61a7855b2364bc3c295df82
+libosmo-netif ADD osmo_stream_srv_link_get_name(), osmo_stream_srv_get_name(), osmo_stream_cli_get_name() \ No newline at end of file
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 2e6aa97..fe4dd77 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -26,6 +26,7 @@ struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx);
void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link);
void osmo_stream_srv_link_set_name(struct osmo_stream_srv_link *link, const char *name);
+const char *osmo_stream_srv_link_get_name(const struct osmo_stream_srv_link *link);
void osmo_stream_srv_link_set_nodelay(struct osmo_stream_srv_link *link, bool nodelay);
void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link, const char *addr);
int osmo_stream_srv_link_set_addrs(struct osmo_stream_srv_link *link, const char **addr, size_t addrcnt);
@@ -60,6 +61,7 @@ struct osmo_stream_srv;
struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, int fd, int (*read_cb)(struct osmo_stream_srv *conn), int (*closed_cb)(struct osmo_stream_srv *conn), void *data);
struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, void *data);
void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name);
+const char *osmo_stream_srv_get_name(const struct osmo_stream_srv *conn);
void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, int (*read_cb)(struct osmo_stream_srv *conn, struct msgb *msg));
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);
@@ -84,6 +86,7 @@ void osmo_stream_srv_clear_tx_queue(struct osmo_stream_srv *conn);
struct osmo_stream_cli;
void osmo_stream_cli_set_name(struct osmo_stream_cli *cli, const char *name);
+const char *osmo_stream_cli_get_name(const struct osmo_stream_cli *cli);
void osmo_stream_cli_set_nodelay(struct osmo_stream_cli *cli, bool nodelay);
void osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr);
int osmo_stream_cli_set_addrs(struct osmo_stream_cli *cli, const char **addr, size_t addrcnt);
diff --git a/src/stream_cli.c b/src/stream_cli.c
index 2f5339c..46ddc89 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -528,6 +528,15 @@ void osmo_stream_cli_set_name(struct osmo_stream_cli *cli, const char *name)
osmo_iofd_set_name(cli->iofd, name);
}
+/*! \brief Retrieve name previously set on the cli object (see osmo_stream_cli_set_name())
+ * \param[in] cli stream_cli whose name is to be retrieved
+ * \returns The name to be set on cli; NULL if never set
+ */
+const char *osmo_stream_cli_get_name(const struct osmo_stream_cli *cli)
+{
+ return cli->name;
+}
+
/*! \brief Set the remote address to which we connect
* \param[in] cli Stream Client to modify
* \param[in] addr Remote IP address
diff --git a/src/stream_srv.c b/src/stream_srv.c
index 95a2cbb..72c5a81 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -206,6 +206,15 @@ void osmo_stream_srv_link_set_name(struct osmo_stream_srv_link *link, const char
osmo_talloc_replace_string(link, &link->name, name);
}
+/*! \brief Retrieve name previously set on the srv_link object (see osmo_stream_srv_link_set_name())
+ * \param[in] link server link whose name is to be retrieved
+ * \returns The name to be set on link; NULL if never set
+ */
+const char *osmo_stream_srv_link_get_name(const struct osmo_stream_srv_link *link)
+{
+ return link->name;
+}
+
/*! \brief Set the NODELAY socket option to avoid Nagle-like behavior
* Setting this to nodelay=true will automatically set the NODELAY
* socket option on any socket established via this server link, before
@@ -837,6 +846,15 @@ void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name)
osmo_iofd_set_name(conn->iofd, name);
}
+/*! \brief Retrieve name previously set on the srv object (see osmo_stream_srv_set_name())
+ * \param[in] conn server whose name is to be retrieved
+ * \returns The name to be set on conn; NULL if never set
+ */
+const char *osmo_stream_srv_get_name(const struct osmo_stream_srv *conn)
+{
+ return conn->name;
+}
+
/*! \brief Set the call-back function when data was read from the stream server socket
* Only for osmo_stream_srv created with osmo_stream_srv_create2()
* \param[in] conn Stream Server to modify