From patchwork Wed May 4 11:02:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 618354 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 3r0FWr24RCz9t3v for ; Wed, 4 May 2016 21:03:20 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 2F5E113DF1; Wed, 4 May 2016 11:03:18 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 1C4D513D96 for ; Wed, 4 May 2016 11:03:12 +0000 (UTC) Received: from mail.sysmocom.de (mail.sysmocom.de [144.76.43.93]) by mail.sysmocom.de (Postfix) with ESMTP id DED2F1BD6C6; Wed, 4 May 2016 11:02:41 +0000 (UTC) Received: from pbell.local (ip5b418565.dynamic.kabel-deutschland.de [91.65.133.101]) by mail.sysmocom.de (Postfix) with ESMTPSA id 903641BD6C5; Wed, 4 May 2016 11:02:41 +0000 (UTC) From: msuraev@sysmocom.de To: openbsc@lists.osmocom.org Subject: [PATCH 3/6] Simplify subscriber creation Date: Wed, 4 May 2016 13:02:35 +0200 Message-Id: <1462359758-11287-3-git-send-email-msuraev@sysmocom.de> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1462359758-11287-1-git-send-email-msuraev@sysmocom.de> References: <1462359758-11287-1-git-send-email-msuraev@sysmocom.de> X-Virus-Scanned: ClamAV using ClamSMTP 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: , Cc: Max Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Max Move common code to wrapper function. --- openbsc/src/libmsc/gsm_04_08.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 05cb886..bb1b49a 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -507,6 +507,14 @@ static int mm_tx_identity_req(struct gsm_subscriber_connection *conn, uint8_t id return gsm48_conn_sendmsg(msg, conn, NULL); } +static struct gsm_subscriber *subscr_create(const struct gsm_network *net, + const char *imsi) +{ + if (GSM_SUBSCR_DONT_CREATE == net->create_subscriber) + return NULL; + + return subscr_create_subscriber(net->subscr_group, imsi); +} /* 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 @@ 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) - 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,9 +648,8 @@ 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) { - 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);