msc: Add and use gsm_subscriber_group
Currently every subcriber object directly refers to the gsm_network
which contains a flag shared by every related subscriber
(keep_subscr). This adds a dependency on gsm_network even if only the
function defined in gsm_subscriber_base.c are used.
This patch adds a new struct gsm_subscriber_group which contains the
keep_subscr flag and a back reference to the network object. The
latter is not dereferenced in gsm_subscriber_base.c, so it can safely
be set to NULL when only that part of the gsm_subscriber API is being
used. It also changes that API to use gsm_subscriber_group instead of
gsm_network parameters.
Since there are some places where a pointer to the gsm_network is
needed but where only a gsm_subscriber is available, a 'net' back
pointer is added to the group struct, too. Nevertheless subscr group
and network could be separated completely, but this is not the topic
of this commit.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c
index 702a7ae..e48c6a3 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -67,9 +67,9 @@
imsi = strtok_r(tmp, ",", &saveptr);
msisdn = strtok_r(NULL, ",", &saveptr);
- subscr = subscr_get_by_imsi(net, imsi);
+ subscr = subscr_get_by_imsi(net->subscr_group, imsi);
if (!subscr)
- subscr = subscr_create_subscriber(net, imsi);
+ subscr = subscr_create_subscriber(net->subscr_group, imsi);
if (!subscr)
goto fail;
@@ -118,7 +118,7 @@
struct gsm_subscriber *subscr;
struct gsm_network *net = cmd->node;
- subscr = subscr_get_by_imsi(net, cmd->value);
+ subscr = subscr_get_by_imsi(net->subscr_group, cmd->value);
if (!subscr) {
cmd->reply = "Failed to find subscriber";
return CTRL_CMD_ERROR;