aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-06-16 15:59:46 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-06-20 13:49:37 +0200
commit08e9b6c6121cc957c36c337e79e738f3e8a38d35 (patch)
tree4ed823ece190eee3b3af57abc65987a45aa5f3ac
parentb04f0384eef5b1a35a4cc660f6f97fd8348987f2 (diff)
stream: Drop recently added API osmo_stream_cli_create2
It was later decided that since setting a name is not really required, it is best to leave it out of the create() function and let the user use the osmo_stream_cli_set_name() API if needed (otherwise a dynamic name based on socket is selected). Change-Id: I2a2fad318ef22c2ac117f95588a078ca3beccea5
-rw-r--r--examples/ipa-stream-client.c3
-rw-r--r--examples/stream-client.c3
-rw-r--r--include/osmocom/netif/stream.h1
-rw-r--r--src/stream.c51
4 files changed, 23 insertions, 35 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c
index 91abfac..b66d93a 100644
--- a/examples/ipa-stream-client.c
+++ b/examples/ipa-stream-client.c
@@ -164,11 +164,12 @@ int main(int argc, char *argv[])
* initialize stream client.
*/
- conn = osmo_stream_cli_create2(tall_test, "ipa_test_client");
+ conn = osmo_stream_cli_create(tall_test);
if (conn == NULL) {
fprintf(stderr, "cannot create client\n");
exit(EXIT_FAILURE);
}
+ osmo_stream_cli_set_name(conn, "ipa_test_client");
osmo_stream_cli_set_addr(conn, "127.0.0.1");
osmo_stream_cli_set_port(conn, 10000);
osmo_stream_cli_set_connect_cb(conn, connect_cb);
diff --git a/examples/stream-client.c b/examples/stream-client.c
index 350535d..6781c72 100644
--- a/examples/stream-client.c
+++ b/examples/stream-client.c
@@ -103,11 +103,12 @@ int main(void)
* initialize stream cli.
*/
- conn = osmo_stream_cli_create2(tall_test, "stream_client");
+ conn = osmo_stream_cli_create(tall_test);
if (conn == NULL) {
fprintf(stderr, "cannot create cli\n");
exit(EXIT_FAILURE);
}
+ osmo_stream_cli_set_name(conn, "stream_client");
osmo_stream_cli_set_addr(conn, "127.0.0.1");
osmo_stream_cli_set_port(conn, 10000);
osmo_stream_cli_set_connect_cb(conn, connect_cb);
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 11e9070..c56b9a6 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -90,7 +90,6 @@ void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli);
bool osmo_stream_cli_is_connected(struct osmo_stream_cli *cli);
struct osmo_stream_cli *osmo_stream_cli_create(void *ctx);
-struct osmo_stream_cli *osmo_stream_cli_create2(void *ctx, const char *name);
void osmo_stream_cli_destroy(struct osmo_stream_cli *cli);
int osmo_stream_cli_open(struct osmo_stream_cli *cli);
diff --git a/src/stream.c b/src/stream.c
index a5a5bf1..8771614 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -576,7 +576,23 @@ static void cli_timer_cb(void *data);
*/
struct osmo_stream_cli *osmo_stream_cli_create(void *ctx)
{
- return osmo_stream_cli_create2(ctx, "");
+ struct osmo_stream_cli *cli;
+
+ cli = talloc_zero(ctx, struct osmo_stream_cli);
+ if (!cli)
+ return NULL;
+
+ cli->mode = OSMO_STREAM_MODE_UNKNOWN;
+ cli->sk_domain = AF_UNSPEC;
+ cli->sk_type = SOCK_STREAM;
+ cli->proto = IPPROTO_TCP;
+
+ cli->state = STREAM_CLI_STATE_CLOSED;
+ osmo_timer_setup(&cli->timer, cli_timer_cb, cli);
+ cli->reconnect_timeout = 5; /* default is 5 seconds. */
+ INIT_LLIST_HEAD(&cli->tx_queue);
+
+ return cli;
}
static void stream_cli_iofd_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg)
@@ -624,35 +640,6 @@ static struct osmo_io_ops osmo_stream_cli_ioops = {
.segmentation_cb = NULL,
};
-/*! \brief Create an Osmocom stream client
- * \param[in] ctx talloc context from which to allocate memory
- * This function allocates a new \ref osmo_stream_cli and initializes
- * it with default values (5s reconnect timer, TCP protocol)
- * \param[in] name a description of the stream client. Will be used in logging
- * \return allocated stream client, or NULL in case of error
- */
-struct osmo_stream_cli *osmo_stream_cli_create2(void *ctx, const char *name)
-{
- struct osmo_stream_cli *cli;
-
- cli = talloc_zero(ctx, struct osmo_stream_cli);
- if (!cli)
- return NULL;
-
- cli->name = talloc_strdup(cli, name);
- cli->mode = OSMO_STREAM_MODE_UNKNOWN;
- cli->sk_domain = AF_UNSPEC;
- cli->sk_type = SOCK_STREAM;
- cli->proto = IPPROTO_TCP;
-
- cli->state = STREAM_CLI_STATE_CLOSED;
- osmo_timer_setup(&cli->timer, cli_timer_cb, cli);
- cli->reconnect_timeout = 5; /* default is 5 seconds. */
- INIT_LLIST_HEAD(&cli->tx_queue);
-
- return cli;
-}
-
/*! \brief Set a name on the cli object (used during logging)
* \param[in] cli stream_cli whose name is to be set
* \param[in] name the name to be set on cli
@@ -875,7 +862,7 @@ void osmo_stream_cli_set_disconnect_cb(struct osmo_stream_cli *cli,
}
/*! \brief Set the call-back function called to read from the stream client socket
- * Only for osmo_stream_cli created with osmo_stream_cli_create()
+ * This function will configure osmo_stream_cli to use osmo_ofd internally.
* \param[in] cli Stream Client to modify
* \param[in] read_cb Call-back function to be called when we want to read */
void
@@ -888,7 +875,7 @@ osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli,
}
/*! \brief Set the call-back function called to read from the stream client socket
- * Only use this function for osmo_stream_cli created with osmo_stream_cli_create2()
+ * This function will configure osmo_stream_cli to use osmo_iofd internally.
* \param[in] cli Stream Client to modify
* \param[in] read_cb Call-back function to be called when data was read from the socket */
void