aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-09-04 17:04:12 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-09-04 17:04:18 +0200
commit962bf9a48eed418354685dc733b8271d2dd62c27 (patch)
tree9a55f021571970f446e420e3cd545bd9158771c6
parent592057bb33dc0c336a63003cd7a3a67944d92757 (diff)
stream: Introduce API osmo_stream_cli_is_connected
Can be used by users to fetch current status of the stream. Change-Id: I5402430e5f39eef22dfa18f33807ab6b1e771f1b
-rw-r--r--include/osmocom/netif/stream.h1
-rw-r--r--src/stream.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index f1c160c..3427df5 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -67,6 +67,7 @@ void osmo_stream_cli_set_connect_cb(struct osmo_stream_cli *cli, int (*connect_c
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));
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);
void osmo_stream_cli_destroy(struct osmo_stream_cli *cli);
diff --git a/src/stream.c b/src/stream.c
index 3d0b665..74fe8b6 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -184,6 +184,14 @@ void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)
cli->state = STREAM_CLI_STATE_CONNECTING;
}
+/*! \brief Check if Osmocom Stream Client is in connected state
+ * \param[in] cli Osmocom Stream Client
+ */
+bool osmo_stream_cli_is_connected(struct osmo_stream_cli *cli)
+{
+ return cli->state == STREAM_CLI_STATE_CONNECTED;
+}
+
/*! \brief Close an Osmocom Stream Client
* \param[in] cli Osmocom Stream Client to be closed
* We unregister the socket fd from the osmocom select() loop