aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/channel/abis_ipa_client.c4
-rw-r--r--examples/channel/abis_ipa_server.c4
-rw-r--r--include/osmocom/netif/channel.h4
-rw-r--r--src/channel.c10
4 files changed, 13 insertions, 9 deletions
diff --git a/examples/channel/abis_ipa_client.c b/examples/channel/abis_ipa_client.c
index f289a63..c560e9f 100644
--- a/examples/channel/abis_ipa_client.c
+++ b/examples/channel/abis_ipa_client.c
@@ -55,10 +55,10 @@ int main(void)
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
/* initialize channel infrastructure. */
- osmo_chan_init();
+ osmo_chan_init(tall_example);
/* create channel. */
- chan = osmo_chan_create(tall_example, OSMO_CHAN_ABIS_IPA_CLI);
+ chan = osmo_chan_create(OSMO_CHAN_ABIS_IPA_CLI);
if (chan == NULL) {
LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA client\n");
exit(EXIT_FAILURE);
diff --git a/examples/channel/abis_ipa_server.c b/examples/channel/abis_ipa_server.c
index 7acbc56..27eebc7 100644
--- a/examples/channel/abis_ipa_server.c
+++ b/examples/channel/abis_ipa_server.c
@@ -52,10 +52,10 @@ int main(void)
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
/* initialize channel infrastructure. */
- osmo_chan_init();
+ osmo_chan_init(tall_example);
/* create channel. */
- chan = osmo_chan_create(tall_example, OSMO_CHAN_ABIS_IPA_SRV);
+ chan = osmo_chan_create(OSMO_CHAN_ABIS_IPA_SRV);
if (chan == NULL) {
LOGP(DEXAMPLE, LOGL_ERROR, "Cannot create A-bis IPA server\n");
exit(EXIT_FAILURE);
diff --git a/include/osmocom/netif/channel.h b/include/osmocom/netif/channel.h
index 6afbed8..f044605 100644
--- a/include/osmocom/netif/channel.h
+++ b/include/osmocom/netif/channel.h
@@ -34,9 +34,9 @@ struct osmo_chan {
char data[0];
};
-void osmo_chan_init(void);
+void osmo_chan_init(void *ctx);
-struct osmo_chan *osmo_chan_create(void *ctx, int type);
+struct osmo_chan *osmo_chan_create(int type);
void osmo_chan_destroy(struct osmo_chan *c);
int osmo_chan_open(struct osmo_chan *c);
diff --git a/src/channel.c b/src/channel.c
index d6e26a8..3b317de 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -10,14 +10,17 @@ static LLIST_HEAD(channel_list);
extern struct osmo_chan_type chan_abis_ipa_srv;
extern struct osmo_chan_type chan_abis_ipa_cli;
-void osmo_chan_init(void)
+static void *osmo_chan_ctx;
+
+void osmo_chan_init(void *ctx)
{
+ osmo_chan_ctx = ctx;
llist_add(&chan_abis_ipa_srv.head, &channel_list);
llist_add(&chan_abis_ipa_cli.head, &channel_list);
/* add your new channel type here */
}
-struct osmo_chan *osmo_chan_create(void *ctx, int type_id)
+struct osmo_chan *osmo_chan_create(int type_id)
{
struct osmo_chan_type *cur = NULL;
int found = 0;
@@ -42,7 +45,8 @@ struct osmo_chan *osmo_chan_create(void *ctx, int type_id)
return NULL;
}
- c = talloc_zero_size(ctx, sizeof(struct osmo_chan) + cur->datasiz);
+ c = talloc_zero_size(osmo_chan_ctx,
+ sizeof(struct osmo_chan) + cur->datasiz);
if (c == NULL) {
LOGP(DLINP, LOGL_ERROR, "cannot allocate channel data\n");
return NULL;