summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2015-10-24 12:20:17 +0300
committerIvan Kluchnikov <kluchnikovi@gmail.com>2015-10-24 13:59:16 +0300
commit3e374dbbb4474a3429fac102baf8446f4ac5f13b (patch)
tree7eb164224e8a0a0cb95e25f5fc0fb020536118be
parent2a01e0411ad817e21e805d6e29696b111cbfa4a9 (diff)
subscr: Add new configuration parameter "subscriber-create-only-local"
This mode allows to create a new record only for a subscriber from our network. IMSI and MNC, MCC are used for checking that subscriber belongs to our network.
-rw-r--r--openbsc/include/openbsc/gsm_data.h1
-rw-r--r--openbsc/src/libbsc/net_init.c1
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c37
-rw-r--r--openbsc/src/libmsc/vty_interface_layer3.c20
4 files changed, 57 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index a426862..9a15653 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -282,6 +282,7 @@ struct gsm_network {
/* subscriber related features */
int create_subscriber;
+ int create_only_local_subscriber;
struct gsm_subscriber_group *subscr_group;
struct gsm_sms_queue *sms_queue;
uint64_t exten_prefix;
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index 16e8146..64955a9 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -49,6 +49,7 @@ struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_cod
net->subscr_group->net = net;
net->create_subscriber = 1;
+ net->create_only_local_subscriber = 0;
net->exten_prefix = 0;
net->country_code = country_code;
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index d6b2cb4..91bd4a3 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -515,9 +515,26 @@ static int mm_rx_id_resp(struct gsm_subscriber_connection *conn, struct msgb *ms
if (!conn->subscr) {
conn->subscr = subscr_get_by_imsi(net->subscr_group,
mi_string);
- if (!conn->subscr && net->create_subscriber)
+
+ if (!conn->subscr && net->create_subscriber
+ && net->create_only_local_subscriber) {
+ char mcc[4];
+ char mnc[3];
+ strncpy(mcc, mi_string, 3);
+ strncpy(mnc, mi_string + 3, 2);
+ if ((atoi(mcc) == net->country_code) &&
+ (atoi(mnc) == net->network_code)) {
+ conn->subscr = subscr_create_subscriber(
+ net->subscr_group, mi_string);
+ }
+ }
+
+ if (!conn->subscr && net->create_subscriber
+ && !net->create_only_local_subscriber) {
conn->subscr = subscr_create_subscriber(
net->subscr_group, mi_string);
+ }
+
}
if (!conn->subscr && conn->loc_operation) {
gsm0408_loc_upd_rej(conn, bts->network->reject_cause);
@@ -633,10 +650,26 @@ static int mm_rx_loc_upd_req(struct gsm_subscriber_connection *conn, struct msgb
/* look up subscriber based on IMSI, create if not found */
subscr = subscr_get_by_imsi(bts->network->subscr_group, mi_string);
- if (!subscr && bts->network->create_subscriber) {
+
+ if (!subscr && bts->network->create_subscriber
+ && bts->network->create_only_local_subscriber) {
+ char mcc[4];
+ char mnc[3];
+ strncpy(mcc, mi_string, 3);
+ strncpy(mnc, mi_string + 3, 2);
+ if ((atoi(mcc) == bts->network->country_code) &&
+ (atoi(mnc) == bts->network->network_code)) {
+ subscr = subscr_create_subscriber(
+ bts->network->subscr_group, mi_string);
+ }
+ }
+
+ if (!subscr && bts->network->create_subscriber
+ && !bts->network->create_only_local_subscriber) {
subscr = subscr_create_subscriber(
bts->network->subscr_group, mi_string);
}
+
if (!subscr) {
gsm0408_loc_upd_rej(conn, bts->network->reject_cause);
release_loc_updating_req(conn, 0);
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index de33126..2ecc27c 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -995,6 +995,24 @@ DEFUN(cfg_nitb_no_subscr_create, cfg_nitb_no_subscr_create_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_nitb_subscr_create_only_local, cfg_nitb_subscr_create_only_local_cmd,
+ "subscriber-create-only-local",
+ "Make a new record only for a local subscriber.\n")
+{
+ struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ gsmnet->create_only_local_subscriber = 1;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nitb_no_subscr_create_only_local, cfg_nitb_no_subscr_create_only_local_cmd,
+ "no subscriber-create-only-local",
+ NO_STR "Make a new record only for a local subscriber.\n")
+{
+ struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ gsmnet->create_only_local_subscriber = 0;
+ return CMD_SUCCESS;
+}
+
static int config_write_nitb(struct vty *vty)
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
@@ -1051,6 +1069,8 @@ int bsc_vty_init_extra(void)
install_node(&nitb_node, config_write_nitb);
install_element(NITB_NODE, &cfg_nitb_subscr_create_cmd);
install_element(NITB_NODE, &cfg_nitb_no_subscr_create_cmd);
+ install_element(NITB_NODE, &cfg_nitb_subscr_create_only_local_cmd);
+ install_element(NITB_NODE, &cfg_nitb_no_subscr_create_only_local_cmd);
return 0;
}