This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/19502 )
Change subject: i460: pass more context to call-back functions
......................................................................
i460: pass more context to call-back functions
When calling a user-provided call-back function for the i460 mux
or demux, always pass a pointer to the osmo_i460_subchan the callback
relates to. This way, the user can walk the i460 data structures
to obtain information about which mux/demux instances is calling.
Change-Id: Id842c72ce371a67fe5df6694e195c281aaf607ab
---
M include/osmocom/gsm/i460_mux.h
M src/gsm/i460_mux.c
M tests/i460_mux/i460_mux_test.c
3 files changed, 14 insertions(+), 9 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/include/osmocom/gsm/i460_mux.h b/include/osmocom/gsm/i460_mux.h
index e7ea9bd..8e39243 100644
--- a/include/osmocom/gsm/i460_mux.h
+++ b/include/osmocom/gsm/i460_mux.h
@@ -36,8 +36,12 @@
OSMO_I460_RATE_8k,
};
-typedef void (*out_cb_bits_t)(void *user_data, const ubit_t *bits, unsigned int num_bits);
-typedef void (*out_cb_bytes_t)(void *user_data, const uint8_t *bytes, unsigned int num_bytes);
+struct osmo_i460_subchan;
+
+typedef void (*out_cb_bits_t)(struct osmo_i460_subchan *schan, void *user_data,
+ const ubit_t *bits, unsigned int num_bits);
+typedef void (*out_cb_bytes_t)(struct osmo_i460_subchan *schan, void *user_data,
+ const uint8_t *bytes, unsigned int num_bytes);
struct osmo_i460_subchan_demux {
/*! bit-buffer for output bits */
@@ -52,7 +56,7 @@
void *user_data;
};
-typedef void (*in_cb_queue_empty_t)(void *user_data);
+typedef void (*in_cb_queue_empty_t)(struct osmo_i460_subchan *schan, void *user_data);
struct osmo_i460_subchan_mux {
/*! list of to-be-transmitted message buffers */
diff --git a/src/gsm/i460_mux.c b/src/gsm/i460_mux.c
index 3b2a589..320e781 100644
--- a/src/gsm/i460_mux.c
+++ b/src/gsm/i460_mux.c
@@ -69,14 +69,14 @@
if (demux->out_idx >= demux->out_bitbuf_size) {
if (demux->out_cb_bits)
- demux->out_cb_bits(demux->user_data, demux->out_bitbuf, demux->out_idx);
+ demux->out_cb_bits(schan, demux->user_data, demux->out_bitbuf, demux->out_idx);
else {
/* pack bits into bytes */
OSMO_ASSERT((demux->out_idx % 8) == 0);
unsigned int num_bytes = demux->out_idx / 8;
uint8_t bytes[num_bytes];
osmo_ubit2pbit(bytes, demux->out_bitbuf, demux->out_idx);
- demux->out_cb_bytes(demux->user_data, bytes, num_bytes);
+ demux->out_cb_bytes(schan, demux->user_data, bytes, num_bytes);
}
demux->out_idx = 0;
}
@@ -137,11 +137,11 @@
schan = &ts->schan[0];
demux = &schan->demux;
if (demux->out_cb_bytes)
- demux->out_cb_bytes(demux->user_data, data, data_len);
+ demux->out_cb_bytes(schan, demux->user_data, data, data_len);
else {
ubit_t bits[data_len*8];
osmo_pbit2ubit(bits, data, data_len*8);
- demux->out_cb_bits(demux->user_data, bits, data_len*8);
+ demux->out_cb_bits(schan, demux->user_data, bits, data_len*8);
}
return;
}
@@ -178,7 +178,7 @@
if (llist_empty(&mux->tx_queue)) {
/* User code now has a last chance to put something into the queue. */
if (mux->in_cb_queue_empty)
- mux->in_cb_queue_empty(mux->user_data);
+ mux->in_cb_queue_empty(schan, mux->user_data);
/* If the queue is still empty, return idle bits */
if (llist_empty(&mux->tx_queue))
diff --git a/tests/i460_mux/i460_mux_test.c b/tests/i460_mux/i460_mux_test.c
index 53144fd..d63b2ae 100644
--- a/tests/i460_mux/i460_mux_test.c
+++ b/tests/i460_mux/i460_mux_test.c
@@ -3,7 +3,8 @@
#include <osmocom/gsm/i460_mux.h>
-static void bits_cb(void *user_data, const ubit_t *bits, unsigned int num_bits)
+static void bits_cb(struct osmo_i460_subchan *schan, void *user_data,
+ const ubit_t *bits, unsigned int num_bits)
{
char *str = user_data;
printf("demux_bits_cb '%s': %s\n", str, osmo_ubit_dump(bits, num_bits));
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19502
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id842c72ce371a67fe5df6694e195c281aaf607ab
Gerrit-Change-Number: 19502
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200803/3f6e80a8/attachment.htm>