aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2012-08-19 00:52:00 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2012-08-19 00:52:00 +0200
commit775c1de0891da2d3b16efada5ee8b99f96d045a1 (patch)
tree3d0c015075c215ca4200b0c165f882195d0ca7e8 /src
parentb71627b1f74f8c7368fd132f7eec3b2dc26d165f (diff)
channel: add subtype ID to osmo_chan_create
This adds the possibility to specify the variant of the channel. This was discussed during the osmocom workshop. Harald wanted a way to say if the channel is using TCP, UDP, DADHDI and so on.
Diffstat (limited to 'src')
-rw-r--r--src/channel.c19
-rw-r--r--src/channel/abis_ipa_client.c1
-rw-r--r--src/channel/abis_ipa_server.c1
3 files changed, 18 insertions, 3 deletions
diff --git a/src/channel.c b/src/channel.c
index 3b317de..2cae973 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -20,10 +20,10 @@ void osmo_chan_init(void *ctx)
/* add your new channel type here */
}
-struct osmo_chan *osmo_chan_create(int type_id)
+struct osmo_chan *osmo_chan_create(int type_id, int subtype_id)
{
struct osmo_chan_type *cur = NULL;
- int found = 0;
+ int found = 0, found_partial = 0;
struct osmo_chan *c;
if (type_id > OSMO_CHAN_MAX) {
@@ -31,11 +31,19 @@ struct osmo_chan *osmo_chan_create(int type_id)
"number `%u'\n", type_id);
return NULL;
}
+ if (subtype_id > OSMO_SUBCHAN_MAX) {
+ LOGP(DLINP, LOGL_ERROR, "unsupported subchannel type "
+ "number `%u'\n", type_id);
+ return NULL;
+ }
llist_for_each_entry(cur, &channel_list, head) {
- if (type_id == cur->type) {
+ if (type_id == cur->type && subtype_id == cur->subtype) {
found = 1;
break;
+ } else if (type_id == cur->type) {
+ found_partial = 1;
+ break;
}
}
@@ -44,6 +52,11 @@ struct osmo_chan *osmo_chan_create(int type_id)
cur->name);
return NULL;
}
+ if (found_partial) {
+ LOGP(DLINP, LOGL_ERROR, "Sorry, channel type `%s' does not "
+ "support subtype `%u'\n", cur->name, subtype_id);
+ return NULL;
+ }
c = talloc_zero_size(osmo_chan_ctx,
sizeof(struct osmo_chan) + cur->datasiz);
diff --git a/src/channel/abis_ipa_client.c b/src/channel/abis_ipa_client.c
index 2a971c7..bb6a1ee 100644
--- a/src/channel/abis_ipa_client.c
+++ b/src/channel/abis_ipa_client.c
@@ -359,6 +359,7 @@ static int rsl_read_cb(struct osmo_stream_cli *conn)
struct osmo_chan_type chan_abis_ipa_cli = {
.type = OSMO_CHAN_ABIS_IPA_CLI,
+ .subtype = OSMO_SUBCHAN_STREAM,
.name = "A-bis IPA client",
.datasiz = sizeof(struct chan_abis_ipa_cli),
.create = chan_abis_ipa_cli_create,
diff --git a/src/channel/abis_ipa_server.c b/src/channel/abis_ipa_server.c
index 7e21f49..6524033 100644
--- a/src/channel/abis_ipa_server.c
+++ b/src/channel/abis_ipa_server.c
@@ -511,6 +511,7 @@ static int rsl_read_cb(struct osmo_stream_srv *conn)
struct osmo_chan_type chan_abis_ipa_srv = {
.type = OSMO_CHAN_ABIS_IPA_SRV,
+ .subtype = OSMO_SUBCHAN_STREAM,
.name = "A-bis IPA server",
.datasiz = sizeof(struct chan_abis_ipa_srv),
.create = chan_abis_ipa_srv_create,