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/tests/db/db_test.c b/openbsc/tests/db/db_test.c
index 75c92d3..62fbb73 100644
--- a/openbsc/tests/db/db_test.c
+++ b/openbsc/tests/db/db_test.c
@@ -31,9 +31,10 @@
#include <inttypes.h>
static struct gsm_network dummy_net;
+static struct gsm_subscriber_group dummy_sgrp;
#define SUBSCR_PUT(sub) \
- sub->net = &dummy_net; \
+ sub->group = &dummy_sgrp; \
subscr_put(sub);
#define COMPARE(original, copy) \
@@ -70,7 +71,7 @@
struct gsm_subscriber *subscr;
subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, "9993245423445");
OSMO_ASSERT(subscr);
- subscr->net = &dummy_net;
+ subscr->group = &dummy_sgrp;
sms = sms_alloc();
sms->receiver = subscr_get(subscr);
@@ -130,7 +131,7 @@
0xd0, 0xf1, 0xfd, 0x06, 0x00 };
rcv_subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, "901010000001111");
- rcv_subscr->net = &dummy_net;
+ rcv_subscr->group = &dummy_sgrp;
sms = db_sms_get(&dummy_net, 1);
OSMO_ASSERT(sms->id == 1);
@@ -159,6 +160,9 @@
osmo_init_logging(&log_info);
log_set_print_filename(osmo_stderr_target, 0);
+ dummy_net.subscr_group = &dummy_sgrp;
+ dummy_sgrp.net = &dummy_net;
+
if (db_init("hlr.sqlite3")) {
printf("DB: Failed to init database. Please check the option settings.\n");
return 1;