summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-12-03 09:28:24 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-05 14:59:02 +0100
commit1e30a28e51b5e8a14b977233858f267f839197d5 (patch)
tree07f0a3f2fc5cf316b40d55cae5f40243b419e5ca
parentdae1f64ba688eaa24aad6ce15a8529bdef788146 (diff)
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
-rw-r--r--openbsc/include/openbsc/gsm_data.h3
-rw-r--r--openbsc/include/openbsc/gsm_subscriber.h28
-rw-r--r--openbsc/src/libbsc/bsc_vty.c4
-rw-r--r--openbsc/src/libbsc/chan_alloc.c2
-rw-r--r--openbsc/src/libbsc/net_init.c8
-rw-r--r--openbsc/src/libbsc/paging.c2
-rw-r--r--openbsc/src/libcommon/gsm_subscriber_base.c22
-rw-r--r--openbsc/src/libmsc/ctrl_commands.c6
-rw-r--r--openbsc/src/libmsc/db.c4
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c37
-rw-r--r--openbsc/src/libmsc/gsm_04_11.c3
-rw-r--r--openbsc/src/libmsc/gsm_subscriber.c35
-rw-r--r--openbsc/src/libmsc/silent_call.c2
-rw-r--r--openbsc/src/libmsc/smpp_openbsc.c4
-rw-r--r--openbsc/src/libmsc/sms_queue.c8
-rw-r--r--openbsc/src/libmsc/token_auth.c6
-rw-r--r--openbsc/src/libmsc/transaction.c2
-rw-r--r--openbsc/src/libmsc/vty_interface_layer3.c14
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_bssap.c2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_filter.c5
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_grace.c7
-rw-r--r--openbsc/src/osmo-nitb/bsc_hack.c2
-rw-r--r--openbsc/tests/channel/channel_test.c5
-rw-r--r--openbsc/tests/db/db_test.c10
24 files changed, 128 insertions, 93 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 8e95e64c8..e237ea2a6 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -14,6 +14,7 @@
#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
struct mncc_sock_state;
+struct gsm_subscriber_group;
#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
@@ -277,7 +278,7 @@ struct gsm_network {
struct osmo_bsc_data *bsc_data;
/* subscriber related features */
- int keep_subscr;
+ struct gsm_subscriber_group *subscr_group;
struct gsm_sms_queue *sms_queue;
/* control interface */
diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index 7e0a419ae..eaf4028da 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -20,6 +20,12 @@
struct vty;
struct sgsn_mm_ctx;
+struct gsm_subscriber_group {
+ struct gsm_network *net;
+
+ int keep_subscr;
+};
+
struct gsm_equipment {
long long unsigned int id;
char imei[GSM_IMEI_LENGTH];
@@ -33,7 +39,7 @@ struct gsm_equipment {
};
struct gsm_subscriber {
- struct gsm_network *net;
+ struct gsm_subscriber_group *group;
long long unsigned int id;
char imsi[GSM_IMSI_LENGTH];
uint32_t tmsi;
@@ -77,25 +83,25 @@ enum gsm_subscriber_update_reason {
struct gsm_subscriber *subscr_get(struct gsm_subscriber *subscr);
struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr);
-struct gsm_subscriber *subscr_create_subscriber(struct gsm_network *net,
+struct gsm_subscriber *subscr_create_subscriber(struct gsm_subscriber_group *sgrp,
const char *imsi);
-struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_subscriber_group *sgrp,
uint32_t tmsi);
-struct gsm_subscriber *subscr_get_by_imsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_imsi(struct gsm_subscriber_group *sgrp,
const char *imsi);
-struct gsm_subscriber *subscr_get_by_extension(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_extension(struct gsm_subscriber_group *sgrp,
const char *ext);
-struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_id(struct gsm_subscriber_group *sgrp,
unsigned long long id);
-struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp,
const char *imsi);
int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason);
void subscr_put_channel(struct gsm_subscriber *subscr);
void subscr_get_channel(struct gsm_subscriber *subscr,
int type, gsm_cbfn *cbfn, void *param);
-struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp,
uint32_t tmsi);
-struct gsm_subscriber *subscr_active_by_imsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_active_by_imsi(struct gsm_subscriber_group *sgrp,
const char *imsi);
int subscr_pending_requests(struct gsm_subscriber *subscr);
@@ -105,9 +111,9 @@ int subscr_pending_kick(struct gsm_subscriber *subscr);
char *subscr_name(struct gsm_subscriber *subscr);
-int subscr_purge_inactive(struct gsm_network *net);
+int subscr_purge_inactive(struct gsm_subscriber_group *sgrp);
void subscr_update_from_db(struct gsm_subscriber *subscr);
-void subscr_expire(struct gsm_network *net);
+void subscr_expire(struct gsm_subscriber_group *sgrp);
int subscr_update_expire_lu(struct gsm_subscriber *subscr, struct gsm_bts *bts);
/* internal */
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 9129059e5..08f9a8e50 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -709,7 +709,7 @@ static int config_write_net(struct vty *vty)
vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE);
vty_out(vty, " subscriber-keep-in-ram %d%s",
- gsmnet->keep_subscr, VTY_NEWLINE);
+ gsmnet->subscr_group->keep_subscr, VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -1510,7 +1510,7 @@ DEFUN(cfg_net_subscr_keep,
"Delete unused subscribers\n" "Keep unused subscribers\n")
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
- gsmnet->keep_subscr = atoi(argv[0]);
+ gsmnet->subscr_group->keep_subscr = atoi(argv[0]);
return CMD_SUCCESS;
}
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index f6eb5af14..cd96c1b38 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -436,7 +436,7 @@ static struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *
struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr)
{
struct gsm_bts *bts;
- struct gsm_network *net = subscr->net;
+ struct gsm_network *net = subscr->group->net;
struct gsm_lchan *lchan;
llist_for_each_entry(bts, &net->bts_list, list) {
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index 1d370203c..5bb8ae2b6 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -19,6 +19,7 @@
#include <openbsc/gsm_data.h>
#include <openbsc/osmo_msc_data.h>
+#include <openbsc/gsm_subscriber.h>
struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
int (*mncc_recv)(struct gsm_network *, struct msgb *))
@@ -35,10 +36,17 @@ struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_cod
return NULL;
}
+ net->subscr_group = talloc_zero(net, struct gsm_subscriber_group);
+ if (!net->subscr_group) {
+ talloc_free(net);
+ return NULL;
+ }
+
/* Init back pointer */
net->bsc_data->auto_off_timeout = -1;
net->bsc_data->network = net;
INIT_LLIST_HEAD(&net->bsc_data->mscs);
+ net->subscr_group->net = net;
net->country_code = country_code;
net->network_code = network_code;
diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c
index 286c57ba9..f0518bbcb 100644
--- a/openbsc/src/libbsc/paging.c
+++ b/openbsc/src/libbsc/paging.c
@@ -389,7 +389,7 @@ void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
* location area of the _bts as reconfiguration of the
* network is probably happening less often.
*/
- bts = gsm_bts_by_lac(subscr->net, subscr->lac, bts);
+ bts = gsm_bts_by_lac(subscr->group->net, subscr->lac, bts);
if (!bts)
break;
diff --git a/openbsc/src/libcommon/gsm_subscriber_base.c b/openbsc/src/libcommon/gsm_subscriber_base.c
index 5e00443c2..3d01ca20d 100644
--- a/openbsc/src/libcommon/gsm_subscriber_base.c
+++ b/openbsc/src/libcommon/gsm_subscriber_base.c
@@ -91,18 +91,18 @@ struct gsm_subscriber *subscr_put(struct gsm_subscriber *subscr)
subscr->use_count--;
DEBUGP(DREF, "subscr %s usage decreased usage to: %d\n",
subscr->extension, subscr->use_count);
- if (subscr->use_count <= 0 && !subscr->net->keep_subscr)
+ if (subscr->use_count <= 0 && !subscr->group->keep_subscr)
subscr_free(subscr);
return NULL;
}
-struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp,
const char *imsi)
{
struct gsm_subscriber *subscr;
llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (strcmp(subscr->imsi, imsi) == 0 && subscr->net == net)
+ if (strcmp(subscr->imsi, imsi) == 0 && subscr->group == sgrp)
return subscr_get(subscr);
}
@@ -112,41 +112,43 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH);
subscr->imsi[GSM_IMSI_LENGTH - 1] = '\0';
- subscr->net = net;
+ subscr->group = sgrp;
return subscr;
}
-struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_network *net, uint32_t tmsi)
+struct gsm_subscriber *subscr_active_by_tmsi(struct gsm_subscriber_group *sgrp,
+ uint32_t tmsi)
{
struct gsm_subscriber *subscr;
llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (subscr->tmsi == tmsi && subscr->net == net)
+ if (subscr->tmsi == tmsi && subscr->group == sgrp)
return subscr_get(subscr);
}
return NULL;
}
-struct gsm_subscriber *subscr_active_by_imsi(struct gsm_network *net, const char *imsi)
+struct gsm_subscriber *subscr_active_by_imsi(struct gsm_subscriber_group *sgrp,
+ const char *imsi)
{
struct gsm_subscriber *subscr;
llist_for_each_entry(subscr, subscr_bsc_active_subscribers(), entry) {
- if (strcmp(subscr->imsi, imsi) == 0 && subscr->net == net)
+ if (strcmp(subscr->imsi, imsi) == 0 && subscr->group == sgrp)
return subscr_get(subscr);
}
return NULL;
}
-int subscr_purge_inactive(struct gsm_network *net)
+int subscr_purge_inactive(struct gsm_subscriber_group *sgrp)
{
struct gsm_subscriber *subscr, *tmp;
int purged = 0;
llist_for_each_entry_safe(subscr, tmp, subscr_bsc_active_subscribers(), entry) {
- if (subscr->net == net && subscr->use_count <= 0) {
+ if (subscr->group == sgrp && subscr->use_count <= 0) {
subscr_free(subscr);
purged += 1;
}
diff --git a/openbsc/src/libmsc/ctrl_commands.c b/openbsc/src/libmsc/ctrl_commands.c
index 702a7ae21..e48c6a3e1 100644
--- a/openbsc/src/libmsc/ctrl_commands.c
+++ b/openbsc/src/libmsc/ctrl_commands.c
@@ -67,9 +67,9 @@ static int set_subscriber_modify(struct ctrl_cmd *cmd, void *data)
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 @@ static int set_subscriber_delete(struct ctrl_cmd *cmd, void *data)
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;
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 656c661b7..bdecbb436 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -1470,7 +1470,7 @@ static struct gsm_sms *sms_from_result(struct gsm_network *net, dbi_result resul
strncpy(sms->dst.addr, daddr, sizeof(sms->dst.addr));
sms->dst.addr[sizeof(sms->dst.addr)-1] = '\0';
}
- sms->receiver = subscr_get_by_extension(net, sms->dst.addr);
+ sms->receiver = subscr_get_by_extension(net->subscr_group, sms->dst.addr);
sms->src.npi = dbi_result_get_ulonglong(result, "src_npi");
sms->src.ton = dbi_result_get_ulonglong(result, "src_ton");
@@ -1597,7 +1597,7 @@ struct gsm_sms *db_sms_get_unsent_for_subscr(struct gsm_subscriber *subscr)
return NULL;
}
- sms = sms_from_result(subscr->net, result);
+ sms = sms_from_result(subscr->group->net, result);
dbi_result_free(result);
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 8916fe638..ede6db389 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -255,7 +255,7 @@ static int authorize_subscriber(struct gsm_loc_updating_operation *loc,
if (loc && (loc->waiting_for_imsi || loc->waiting_for_imei))
return 0;
- switch (subscriber->net->auth_policy) {
+ switch (subscriber->group->net->auth_policy) {
case GSM_AUTH_POLICY_CLOSED:
return subscriber->authorized;
case GSM_AUTH_POLICY_TOKEN:
@@ -498,9 +498,11 @@ static int mm_rx_id_resp(struct gsm_subscriber_connection *conn, struct msgb *ms
case GSM_MI_TYPE_IMSI:
/* look up subscriber based on IMSI, create if not found */
if (!conn->subscr) {
- conn->subscr = subscr_get_by_imsi(net, mi_string);
+ conn->subscr = subscr_get_by_imsi(net->subscr_group,
+ mi_string);
if (!conn->subscr)
- conn->subscr = subscr_create_subscriber(net, mi_string);
+ conn->subscr = subscr_create_subscriber(
+ net->subscr_group, mi_string);
}
if (conn->loc_operation)
conn->loc_operation->waiting_for_imsi = 0;
@@ -610,15 +612,16 @@ static int mm_rx_loc_upd_req(struct gsm_subscriber_connection *conn, struct msgb
conn->loc_operation->waiting_for_imei = 1;
/* look up subscriber based on IMSI, create if not found */
- subscr = subscr_get_by_imsi(bts->network, mi_string);
+ subscr = subscr_get_by_imsi(bts->network->subscr_group, mi_string);
if (!subscr) {
- subscr = subscr_create_subscriber(bts->network, mi_string);
+ subscr = subscr_create_subscriber(
+ bts->network->subscr_group, mi_string);
}
break;
case GSM_MI_TYPE_TMSI:
DEBUGPC(DMM, "\n");
/* look up the subscriber based on TMSI, request IMSI if it fails */
- subscr = subscr_get_by_tmsi(bts->network,
+ subscr = subscr_get_by_tmsi(bts->network->subscr_group,
tmsi_from_string(mi_string));
if (!subscr) {
/* send IDENTITY REQUEST message to get IMSI */
@@ -948,7 +951,7 @@ static int gsm48_rx_mm_serv_req(struct gsm_subscriber_connection *conn, struct m
if (is_siemens_bts(bts))
send_siemens_mrpci(msg->lchan, classmark2-1);
- subscr = subscr_get_by_tmsi(bts->network,
+ subscr = subscr_get_by_tmsi(bts->network->subscr_group,
tmsi_from_string(mi_string));
/* FIXME: if we don't know the TMSI, inquire abit IMSI and allocate new TMSI */
@@ -995,12 +998,13 @@ static int gsm48_rx_mm_imsi_detach_ind(struct gsm_subscriber_connection *conn, s
switch (mi_type) {
case GSM_MI_TYPE_TMSI:
DEBUGPC(DMM, "\n");
- subscr = subscr_get_by_tmsi(bts->network,
+ subscr = subscr_get_by_tmsi(bts->network->subscr_group,
tmsi_from_string(mi_string));
break;
case GSM_MI_TYPE_IMSI:
DEBUGPC(DMM, "\n");
- subscr = subscr_get_by_imsi(bts->network, mi_string);
+ subscr = subscr_get_by_imsi(bts->network->subscr_group,
+ mi_string);
break;
case GSM_MI_TYPE_IMEI:
case GSM_MI_TYPE_IMEISV:
@@ -1145,11 +1149,12 @@ static int gsm48_rx_rr_pag_resp(struct gsm_subscriber_connection *conn, struct m
switch (mi_type) {
case GSM_MI_TYPE_TMSI:
- subscr = subscr_get_by_tmsi(bts->network,
+ subscr = subscr_get_by_tmsi(bts->network->subscr_group,
tmsi_from_string(mi_string));
break;
case GSM_MI_TYPE_IMSI:
- subscr = subscr_get_by_imsi(bts->network, mi_string);
+ subscr = subscr_get_by_imsi(bts->network->subscr_group,
+ mi_string);
break;
}
@@ -3040,10 +3045,11 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
}
/* New transaction due to setup, find subscriber */
if (data->called.number[0])
- subscr = subscr_get_by_extension(net,
+ subscr = subscr_get_by_extension(net->subscr_group,
data->called.number);
else
- subscr = subscr_get_by_imsi(net, data->imsi);
+ subscr = subscr_get_by_imsi(net->subscr_group,
+ data->imsi);
/* update the subscriber we deal with */
log_set_context(BSC_CTX_SUBSCR, subscr);
@@ -3107,7 +3113,8 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
memcpy(&trans->cc.msg, data, sizeof(struct gsm_mncc));
/* Get a channel */
- trans->paging_request = talloc_zero(subscr->net, struct gsm_network*);
+ trans->paging_request = talloc_zero(subscr->group->net,
+ struct gsm_network*);
if (!trans->paging_request) {
LOGP(DCC, LOGL_ERROR, "Failed to allocate paging token.\n");
subscr_put(subscr);
@@ -3115,7 +3122,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
return 0;
}
- *trans->paging_request = subscr->net;
+ *trans->paging_request = subscr->group->net;
subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, setup_trig_pag_evt, trans->paging_request);
subscr_put(subscr);
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 1c46b96b0..bc9d59e71 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -392,7 +392,8 @@ static int gsm340_rx_tpdu(struct gsm_subscriber_connection *conn, struct msgb *m
send_signal(0, NULL, gsms, 0);
/* determine gsms->receiver based on dialled number */
- gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dst.addr);
+ gsms->receiver = subscr_get_by_extension(conn->bts->network->subscr_group,
+ gsms->dst.addr);
if (!gsms->receiver) {
#ifdef BUILD_SMPP
rc = smpp_try_deliver(gsms, conn);
diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c
index bc6f3cf55..c444fe058 100644
--- a/openbsc/src/libmsc/gsm_subscriber.c
+++ b/openbsc/src/libmsc/gsm_subscriber.c
@@ -78,12 +78,12 @@ enum {
REQ_STATE_DISPATCHED,
};
-static struct gsm_subscriber *get_subscriber(struct gsm_network *net,
+static struct gsm_subscriber *get_subscriber(struct gsm_subscriber_group *sgrp,
int type, const char *ident)
{
struct gsm_subscriber *subscr = db_get_subscriber(type, ident);
if (subscr)
- subscr->net = net;
+ subscr->group = sgrp;
return subscr;
}
@@ -199,12 +199,13 @@ static void subscr_send_paging_request(struct gsm_subscriber *subscr)
{
struct subscr_request *request;
int rc;
+ struct gsm_network *net = subscr->group->net;
assert(!llist_empty(&subscr->requests));
request = (struct subscr_request *)subscr->requests.next;
request->state = REQ_STATE_PAGED;
- rc = paging_request(subscr->net, subscr, request->channel_type,
+ rc = paging_request(net, subscr, request->channel_type,
subscr_paging_cb, subscr);
/* paging failed, quit now */
@@ -275,16 +276,16 @@ void subscr_put_channel(struct gsm_subscriber *subscr)
subscr_send_paging_request(subscr);
}
-struct gsm_subscriber *subscr_create_subscriber(struct gsm_network *net,
+struct gsm_subscriber *subscr_create_subscriber(struct gsm_subscriber_group *sgrp,
const char *imsi)
{
struct gsm_subscriber *subscr = db_create_subscriber(imsi);
if (subscr)
- subscr->net = net;
+ subscr->group = sgrp;
return subscr;
}
-struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_subscriber_group *sgrp,
uint32_t tmsi)
{
char tmsi_string[14];
@@ -297,10 +298,10 @@ struct gsm_subscriber *subscr_get_by_tmsi(struct gsm_network *net,
}
sprintf(tmsi_string, "%u", tmsi);
- return get_subscriber(net, GSM_SUBSCRIBER_TMSI, tmsi_string);
+ return get_subscriber(sgrp, GSM_SUBSCRIBER_TMSI, tmsi_string);
}
-struct gsm_subscriber *subscr_get_by_imsi(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_imsi(struct gsm_subscriber_group *sgrp,
const char *imsi)
{
struct gsm_subscriber *subscr;
@@ -310,10 +311,10 @@ struct gsm_subscriber *subscr_get_by_imsi(struct gsm_network *net,
return subscr_get(subscr);
}
- return get_subscriber(net, GSM_SUBSCRIBER_IMSI, imsi);
+ return get_subscriber(sgrp, GSM_SUBSCRIBER_IMSI, imsi);
}
-struct gsm_subscriber *subscr_get_by_extension(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_extension(struct gsm_subscriber_group *sgrp,
const char *ext)
{
struct gsm_subscriber *subscr;
@@ -323,10 +324,10 @@ struct gsm_subscriber *subscr_get_by_extension(struct gsm_network *net,
return subscr_get(subscr);
}
- return get_subscriber(net, GSM_SUBSCRIBER_EXTENSION, ext);
+ return get_subscriber(sgrp, GSM_SUBSCRIBER_EXTENSION, ext);
}
-struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
+struct gsm_subscriber *subscr_get_by_id(struct gsm_subscriber_group *sgrp,
unsigned long long id)
{
struct gsm_subscriber *subscr;
@@ -338,7 +339,7 @@ struct gsm_subscriber *subscr_get_by_id(struct gsm_network *net,
return subscr_get(subscr);
}
- return get_subscriber(net, GSM_SUBSCRIBER_ID, buf);
+ return get_subscriber(sgrp, GSM_SUBSCRIBER_ID, buf);
}
int subscr_update_expire_lu(struct gsm_subscriber *s, struct gsm_bts *bts)
@@ -370,7 +371,7 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
/* FIXME: Migrate pending requests from one BSC to another */
switch (reason) {
case GSM_SUBSCRIBER_UPDATE_ATTACHED:
- s->net = bts->network;
+ s->group = bts->network->subscr_group;
/* Indicate "attached to LAC" */
s->lac = bts->location_area_code;
@@ -412,7 +413,7 @@ void subscr_update_from_db(struct gsm_subscriber *sub)
static void subscr_expire_callback(void *data, long long unsigned int id)
{
struct gsm_network *net = data;
- struct gsm_subscriber *s = subscr_get_by_id(net, id);
+ struct gsm_subscriber *s = subscr_get_by_id(net->subscr_group, id);
struct gsm_subscriber_connection *conn = connection_for_subscr(s);
/*
@@ -438,9 +439,9 @@ static void subscr_expire_callback(void *data, long long unsigned int id)
subscr_put(s);
}
-void subscr_expire(struct gsm_network *net)
+void subscr_expire(struct gsm_subscriber_group *sgrp)
{
- db_subscriber_expire(net, subscr_expire_callback);
+ db_subscriber_expire(sgrp->net, subscr_expire_callback);
}
int subscr_pending_requests(struct gsm_subscriber *sub)
diff --git a/openbsc/src/libmsc/silent_call.c b/openbsc/src/libmsc/silent_call.c
index 4462dfcba..010c2b4d2 100644
--- a/openbsc/src/libmsc/silent_call.c
+++ b/openbsc/src/libmsc/silent_call.c
@@ -120,7 +120,7 @@ int gsm_silent_call_start(struct gsm_subscriber *subscr, void *data, int type)
{
int rc;
- rc = paging_request(subscr->net, subscr, type,
+ rc = paging_request(subscr->group->net, subscr, type,
paging_cb_silent, data);
return rc;
}
diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c
index 7e14c74bb..686131762 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -55,11 +55,11 @@ static struct gsm_subscriber *subscr_by_dst(struct gsm_network *net,
switch (npi) {
case NPI_Land_Mobile_E212:
- subscr = subscr_get_by_imsi(net, addr);
+ subscr = subscr_get_by_imsi(net->subscr_group, addr);
break;
case NPI_ISDN_E163_E164:
case NPI_Private:
- subscr = subscr_get_by_extension(net, addr);
+ subscr = subscr_get_by_extension(net->subscr_group, addr);
break;
default:
LOGP(DSMPP, LOGL_NOTICE, "Unsupported NPI: %u\n", npi);
diff --git a/openbsc/src/libmsc/sms_queue.c b/openbsc/src/libmsc/sms_queue.c
index 536bfdd14..3ed8b562a 100644
--- a/openbsc/src/libmsc/sms_queue.c
+++ b/openbsc/src/libmsc/sms_queue.c
@@ -135,7 +135,7 @@ static void sms_pending_resend(struct gsm_sms_pending *pending)
pending->resend = 1;
- smsq = pending->subscr->net->sms_queue;
+ smsq = pending->subscr->group->net->sms_queue;
if (osmo_timer_pending(&smsq->resend_pending))
return;
@@ -149,7 +149,7 @@ static void sms_pending_failed(struct gsm_sms_pending *pending, int paging_error
LOGP(DLSMS, LOGL_NOTICE, "Sending SMS %llu failed %d times.\n",
pending->sms_id, pending->failed_attempts);
- smsq = pending->subscr->net->sms_queue;
+ smsq = pending->subscr->group->net->sms_queue;
if (++pending->failed_attempts < smsq->max_fail)
return sms_pending_resend(pending);
@@ -285,7 +285,7 @@ static void sms_submit_pending(void *_data)
*/
static void sms_send_next(struct gsm_subscriber *subscr)
{
- struct gsm_sms_queue *smsq = subscr->net->sms_queue;
+ struct gsm_sms_queue *smsq = subscr->group->net->sms_queue;
struct gsm_sms_pending *pending;
struct gsm_sms *sms;
@@ -316,7 +316,7 @@ static void sms_send_next(struct gsm_subscriber *subscr)
no_pending_sms:
/* Try to send the SMS to avoid the queue being stuck */
- sms_submit_pending(subscr->net->sms_queue);
+ sms_submit_pending(subscr->group->net->sms_queue);
}
/*
diff --git a/openbsc/src/libmsc/token_auth.c b/openbsc/src/libmsc/token_auth.c
index 45b5a8eab..95fd9b345 100644
--- a/openbsc/src/libmsc/token_auth.c
+++ b/openbsc/src/libmsc/token_auth.c
@@ -59,7 +59,7 @@ static int token_subscr_cb(unsigned int subsys, unsigned int signal,
if (signal != S_SUBSCR_ATTACHED)
return 0;
- if (subscr->net->auth_policy != GSM_AUTH_POLICY_TOKEN)
+ if (subscr->group->net->auth_policy != GSM_AUTH_POLICY_TOKEN)
return 0;
if (subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT) {
@@ -82,7 +82,7 @@ static int token_subscr_cb(unsigned int subsys, unsigned int signal,
/* FIXME: don't use ID 1 static */
- sender = subscr_get_by_id(subscr->net, 1);
+ sender = subscr_get_by_id(subscr->group, 1);
sms = sms_from_text(subscr, sender, 0, sms_str);
@@ -136,7 +136,7 @@ static int token_sms_cb(unsigned int subsys, unsigned int signal,
return 0;
- if (sms->receiver->net->auth_policy != GSM_AUTH_POLICY_TOKEN)
+ if (sms->receiver->group->net->auth_policy != GSM_AUTH_POLICY_TOKEN)
return 0;
diff --git a/openbsc/src/libmsc/transaction.c b/openbsc/src/libmsc/transaction.c
index 4d3aeacf1..5621067c0 100644
--- a/openbsc/src/libmsc/transaction.c
+++ b/openbsc/src/libmsc/transaction.c
@@ -66,7 +66,7 @@ struct gsm_trans *trans_alloc(struct gsm_subscriber *subscr,
uint32_t callref)
{
struct gsm_trans *trans;
- struct gsm_network *net = subscr->net;
+ struct gsm_network *net = subscr->group->net;
DEBUGP(DCC, "subscr=%p, net=%p\n", subscr, net);
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 8890099c6..f9213f542 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -169,7 +169,7 @@ static int _send_sms_str(struct gsm_subscriber *receiver,
}
sms_free(sms);
- sms_queue_trigger(receiver->net->sms_queue);
+ sms_queue_trigger(receiver->group->net->sms_queue);
return CMD_SUCCESS;
}
@@ -178,13 +178,13 @@ static struct gsm_subscriber *get_subscr_by_argv(struct gsm_network *gsmnet,
const char *id)
{
if (!strcmp(type, "extension"))
- return subscr_get_by_extension(gsmnet, id);
+ return subscr_get_by_extension(gsmnet->subscr_group, id);
else if (!strcmp(type, "imsi"))
- return subscr_get_by_imsi(gsmnet, id);
+ return subscr_get_by_imsi(gsmnet->subscr_group, id);
else if (!strcmp(type, "tmsi"))
- return subscr_get_by_tmsi(gsmnet, atoi(id));
+ return subscr_get_by_tmsi(gsmnet->subscr_group, atoi(id));
else if (!strcmp(type, "id"))
- return subscr_get_by_id(gsmnet, atoi(id));
+ return subscr_get_by_id(gsmnet->subscr_group, atoi(id));
return NULL;
}
@@ -229,7 +229,7 @@ DEFUN(subscriber_create,
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
struct gsm_subscriber *subscr;
- subscr = subscr_create_subscriber(gsmnet, argv[0]);
+ subscr = subscr_create_subscriber(gsmnet->subscr_group, argv[0]);
if (!subscr) {
vty_out(vty, "%% No subscriber created for IMSI %s%s",
argv[0], VTY_NEWLINE);
@@ -779,7 +779,7 @@ DEFUN(subscriber_purge,
struct gsm_network *net = gsmnet_from_vty(vty);
int purged;
- purged = subscr_purge_inactive(net);
+ purged = subscr_purge_inactive(net->subscr_group);
vty_out(vty, "%d subscriber(s) were purged.%s", purged, VTY_NEWLINE);
return CMD_SUCCESS;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
index dda31578e..a801e0e69 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_bssap.c
@@ -167,7 +167,7 @@ static int bssmap_handle_paging(struct osmo_msc_data *msc,
LOGP(DMSC, LOGL_ERROR, "eMLPP is not handled\n");
}
- subscr = subscr_get_or_create(msc->network, mi_string);
+ subscr = subscr_get_or_create(msc->network->subscr_group, mi_string);
if (!subscr) {
LOGP(DMSC, LOGL_ERROR, "Failed to allocate a subscriber for %s\n", mi_string);
return -1;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_filter.c b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
index 608f52552..596bfbdc1 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_filter.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_filter.c
@@ -78,11 +78,12 @@ static struct gsm_subscriber *extract_sub(struct gsm_subscriber_connection *conn
switch (mi_type) {
case GSM_MI_TYPE_TMSI:
- subscr = subscr_active_by_tmsi(conn->bts->network,
+ subscr = subscr_active_by_tmsi(conn->bts->network->subscr_group,
tmsi_from_string(mi_string));
break;
case GSM_MI_TYPE_IMSI:
- subscr = subscr_active_by_imsi(conn->bts->network, mi_string);
+ subscr = subscr_active_by_imsi(conn->bts->network->subscr_group,
+ mi_string);
break;
default:
subscr = NULL;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_grace.c b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
index 4e1c79ebd..aa268a40a 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_grace.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_grace.c
@@ -41,7 +41,7 @@ int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed,
{
struct gsm_bts *bts = NULL;
- if (subscr->net->bsc_data->rf_ctrl->policy == S_RF_ON)
+ if (subscr->group->net->bsc_data->rf_ctrl->policy == S_RF_ON)
goto page;
/*
@@ -49,7 +49,7 @@ int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed,
* with NULL and iterate through all bts.
*/
do {
- bts = gsm_bts_by_lac(subscr->net, subscr->lac, bts);
+ bts = gsm_bts_by_lac(subscr->group->net, subscr->lac, bts);
if (!bts)
break;
@@ -68,7 +68,8 @@ int bsc_grace_paging_request(struct gsm_subscriber *subscr, int chan_needed,
/* All bts are either off or in the grace period */
return 0;
page:
- return paging_request(subscr->net, subscr, chan_needed, NULL, msc);
+ return paging_request(subscr->group->net, subscr, chan_needed, NULL,
+ msc);
}
static int handle_sub(struct gsm_lchan *lchan, const char *text)
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index 031cb994d..753fd88cc 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -228,7 +228,7 @@ static void db_sync_timer_cb(void *data)
static void subscr_expire_cb(void *data)
{
- subscr_expire(bsc_gsmnet);
+ subscr_expire(bsc_gsmnet->subscr_group);
osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
}
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index 9fb1e9e9a..236933949 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -74,7 +74,10 @@ int main(int argc, char **argv)
/* Create a dummy subscriber */
struct gsm_subscriber *subscr = subscr_alloc();
subscr->lac = 23;
- subscr->net = network;
+ subscr->group = network->subscr_group;
+
+ OSMO_ASSERT(subscr->group);
+ OSMO_ASSERT(subscr->group->net == network);
/* Ask for a channel... */
subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c
index 75c92d309..62fbb732e 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 @@ static void test_sms(void)
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 @@ static void test_sms_migrate(void)
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 @@ int main()
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;