arehbein has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-netif/+/32811
)
Change subject: stream: Simplify code/fix client segmentation
......................................................................
stream: Simplify code/fix client segmentation
Required change: Ie45402ad8e86e3cecf75ad78a512c17e61e68b19
Related: OS#5751
Change-Id: Ie5e40d47b2bbc63b5c4a2446ea75d22a3e427354
---
M include/osmocom/netif/stream.h
M src/stream.c
2 files changed, 25 insertions(+), 6 deletions(-)
Objections:
Jenkins Builder: Fails
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index cd1dd22..fa76d96 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -23,8 +23,8 @@
/*! \brief Type of protocol transported by the data stream */
enum osmo_stream_proto {
- OSMO_STREAM_UNSPECIFIED = -1,
- OSMO_STREAM_IPAC = 0,
+ OSMO_STREAM_UNSPECIFIED = 0,
+ OSMO_STREAM_IPAC,
/* TODO: Add protocols for which libosmo-netif should be able to handle segmentation */
_NUM_OSMO_STREAM_PROTOS
};
diff --git a/src/stream.c b/src/stream.c
index 421c951..b17bd10 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -89,6 +89,7 @@
//static int (*segmentation_cbs[_NUM_OSMO_STREAM_PROTOS][_NUM_CB_TYPES])(struct msgb *,
int) = {
// [OSMO_STREAM_IPAC][CB_TYPE_SEGM] = ipa_segmentation_cb,
static int (*segmentation_cbs[_NUM_OSMO_STREAM_PROTOS])(struct msgb *) = {
+ [OSMO_STREAM_UNSPECIFIED] = NULL,
[OSMO_STREAM_IPAC] = ipa_segmentation_cb,
};
@@ -814,7 +815,15 @@
*/
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;
}
@@ -1455,10 +1464,7 @@
return;
}
link->stream_proto = osp;
- if (osp != OSMO_STREAM_UNSPECIFIED)
- srv_ioops.segmentation_cb = segmentation_cbs[osp];
- else
- srv_ioops.segmentation_cb = NULL;
+ srv_ioops.segmentation_cb = segmentation_cbs[osp];
link->flags |= OSMO_STREAM_SRV_F_RECONF;
}
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-netif/+/32811
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: arehbein/osmo_io_ipa
Gerrit-Change-Id: Ie5e40d47b2bbc63b5c4a2446ea75d22a3e427354
Gerrit-Change-Number: 32811
Gerrit-PatchSet: 2
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-MessageType: merged