From patchwork Fri May 20 16:32:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerrit-no-reply@lists.osmocom.org X-Patchwork-Id: 624560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3rBD4S4B5Tz9t7G for ; Sat, 21 May 2016 02:32:40 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id A6DFC6E0C; Fri, 20 May 2016 16:32:38 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from 127.0.1.12 (unknown [127.0.1.12]) by lists.osmocom.org (Postfix) with ESMTPA id 496176DF4; Fri, 20 May 2016 16:32:37 +0000 (UTC) Date: Fri, 20 May 2016 16:32:37 +0000 From: Holger Freyther To: Max X-Gerrit-MessageType: merged Subject: [MERGED] openbsc[master]: Make extending subscriber creation easier X-Gerrit-Change-Id: I3b10a9a764fd3a7bb96717a990e52caae16266da X-Gerrit-ChangeURL: X-Gerrit-Commit: e21cf38da4ae4fe89845a48f5af055439f33818b In-Reply-To: References: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/2.12.2-31-gb331dbd-dirty X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: holger@freyther.de Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Message-Id: <20160520163238.A6DFC6E0C@lists.osmocom.org> Holger Freyther has submitted this change and it was merged. Change subject: Make extending subscriber creation easier ...................................................................... Make extending subscriber creation easier * rename variable controlling subscriber creation * use enum for subscriber creation policy * move check for subscriber creation policy into separate static function Related: OS#1658, OS#1647 Change-Id: I3b10a9a764fd3a7bb96717a990e52caae16266da Reviewed-on: https://gerrit.osmocom.org/42 Tested-by: Jenkins Builder Reviewed-by: Holger Freyther --- M openbsc/include/openbsc/gsm_data.h M openbsc/src/libbsc/net_init.c M openbsc/src/libmsc/gsm_04_08.c M openbsc/src/libmsc/vty_interface_layer3.c 4 files changed, 23 insertions(+), 12 deletions(-) Approvals: Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index 91d84db..a08938c 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -19,6 +19,11 @@ #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] +enum gsm_subscr_creation_mode { + GSM_SUBSCR_DONT_CREATE = 0, + GSM_SUBSCR_CREAT_W_RAND_EXT = 1, +}; + enum gsm_security_event { GSM_SECURITY_NOAVAIL, GSM_SECURITY_AUTH_FAILED, @@ -278,7 +283,7 @@ struct osmo_bsc_data *bsc_data; /* subscriber related features */ - int create_subscriber; + int subscr_creation_mode; struct gsm_subscriber_group *subscr_group; struct gsm_sms_queue *sms_queue; diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c index 568a0b8..afcaaf3 100644 --- a/openbsc/src/libbsc/net_init.c +++ b/openbsc/src/libbsc/net_init.c @@ -48,7 +48,7 @@ INIT_LLIST_HEAD(&net->bsc_data->mscs); net->subscr_group->net = net; - net->create_subscriber = 1; + net->subscr_creation_mode = GSM_SUBSCR_CREAT_W_RAND_EXT; net->country_code = country_code; net->network_code = network_code; diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index f02f784..0f00db1 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -507,6 +507,14 @@ return gsm48_conn_sendmsg(msg, conn, NULL); } +static struct gsm_subscriber *subscr_create(const struct gsm_network *net, + const char *imsi) +{ + if (net->subscr_creation_mode != GSM_SUBSCR_DONT_CREATE) + return subscr_create_subscriber(net->subscr_group, imsi); + + return NULL; +} /* Parse Chapter 9.2.11 Identity Response */ static int mm_rx_id_resp(struct gsm_subscriber_connection *conn, struct msgb *msg) @@ -530,9 +538,8 @@ if (!conn->subscr) { conn->subscr = subscr_get_by_imsi(net->subscr_group, mi_string); - if (!conn->subscr && net->create_subscriber) - conn->subscr = subscr_create_subscriber( - net->subscr_group, mi_string); + if (!conn->subscr) + conn->subscr = subscr_create(net, mi_string); } if (!conn->subscr && conn->loc_operation) { gsm0408_loc_upd_rej(conn, bts->network->reject_cause); @@ -641,10 +648,9 @@ /* 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) { - subscr = subscr_create_subscriber( - bts->network->subscr_group, mi_string); - } + if (!subscr) + subscr = subscr_create(bts->network, 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 4c2088a..5d74e04 100644 --- a/openbsc/src/libmsc/vty_interface_layer3.c +++ b/openbsc/src/libmsc/vty_interface_layer3.c @@ -1036,7 +1036,7 @@ "Make a new record when a subscriber is first seen.\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->create_subscriber = 1; + gsmnet->subscr_creation_mode = GSM_SUBSCR_CREAT_W_RAND_EXT; return CMD_SUCCESS; } @@ -1045,7 +1045,7 @@ NO_STR "Make a new record when a subscriber is first seen.\n") { struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->create_subscriber = 0; + gsmnet->subscr_creation_mode = GSM_SUBSCR_DONT_CREATE; return CMD_SUCCESS; } @@ -1072,7 +1072,7 @@ struct gsm_network *gsmnet = gsmnet_from_vty(vty); vty_out(vty, "nitb%s", VTY_NEWLINE); vty_out(vty, " %ssubscriber-create-on-demand%s", - gsmnet->create_subscriber ? "" : "no ", VTY_NEWLINE); + gsmnet->subscr_creation_mode ? "" : "no ", VTY_NEWLINE); vty_out(vty, " %sassign-tmsi%s", gsmnet->avoid_tmsi ? "no " : "", VTY_NEWLINE); return CMD_SUCCESS;