arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/33198 )
Change subject: stream: Add client-side (segmentation) support for IPAC ......................................................................
stream: Add client-side (segmentation) support for IPAC
With this commit, IPAC segmentation is taken care of by setting the protocol being streamed
Depends on change I3a639e6896cc3b3fc8e9b2e1a58254710efa0d3f
Related: OS#5753, OS#5751 Change-Id: I822abf52c6ae396c90b5c50228a0a39c848d3de6 --- M include/osmocom/netif/stream.h M src/stream.c 2 files changed, 36 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/98/33198/1
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index c9b7a88..fa76d96 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -82,6 +82,7 @@ int osmo_stream_cli_set_type(struct osmo_stream_cli *cli, int type); int osmo_stream_cli_set_domain(struct osmo_stream_cli *cli, int domain); void osmo_stream_cli_set_proto(struct osmo_stream_cli *cli, uint16_t proto); +void osmo_stream_cli_set_stream_proto(struct osmo_stream_cli *cli, enum osmo_stream_proto osp); void osmo_stream_cli_set_local_addr(struct osmo_stream_cli *cli, const char *addr); int osmo_stream_cli_set_local_addrs(struct osmo_stream_cli *cli, const char **addr, size_t addrcnt); void osmo_stream_cli_set_local_port(struct osmo_stream_cli *cli, uint16_t port); diff --git a/src/stream.c b/src/stream.c index a033455..ea7e9b2 100644 --- a/src/stream.c +++ b/src/stream.c @@ -278,6 +278,7 @@ int sk_domain; int sk_type; uint16_t proto; + enum osmo_stream_proto stream_proto; int (*connect_cb)(struct osmo_stream_cli *cli); int (*disconnect_cb)(struct osmo_stream_cli *cli); int (*read_cb)(struct osmo_stream_cli *cli); @@ -685,6 +686,7 @@ cli->sk_domain = AF_UNSPEC; cli->sk_type = SOCK_STREAM; cli->proto = IPPROTO_TCP; + cli->stream_proto = OSMO_STREAM_UNSPECIFIED;
cli->iofd = osmo_iofd_setup(ctx, -1, name, OSMO_IO_FD_MODE_READ_WRITE, &osmo_stream_cli_ioops, cli);
@@ -799,6 +801,25 @@ cli->flags |= OSMO_STREAM_CLI_F_RECONF; }
+/*! \brief Set the protocol streamed on the client socket + * \param[in] cli Stream Client to modify + * \param[in] osp Protocol being streamed + */ +void osmo_stream_cli_set_stream_proto(struct osmo_stream_cli *cli, enum osmo_stream_proto osp) +{ + if (!(OSMO_STREAM_UNSPECIFIED <= osp && osp < _NUM_OSMO_STREAM_PROTOS)) { + LOGSCLI(cli, LOGL_ERROR, "Unexpected value (%d) for variable of type " + "'enum osmo_stream_proto'\n", osp); + return; + } + cli->stream_proto = osp; + struct osmo_io_ops client_ops = osmo_stream_cli_ioops; + client_ops.segmentation_cb = segmentation_cbs[osp]; + osmo_iofd_set_ioops(cli->iofd, &client_ops); + cli->flags |= OSMO_STREAM_CLI_F_RECONF; + osmo_iofd_set_ioops(cli->iofd, &osmo_stream_cli_ioops); +} + /*! \brief Set the socket type for the stream server link * \param[in] cli Stream Client to modify * \param[in] type Socket Type (like SOCK_STREAM (default), SOCK_SEQPACKET, ...)