blob: 58a6ff089dfea9fdafe9b50677eafb0e5e1af3ec [file] [log] [blame]
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +02001/* The concept of a subscriber as seen by the BSC */
2
3/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther66efcbc2010-06-30 09:22:31 +08004 * (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
Holger Hans Peter Freyther85531cc2010-10-06 20:37:09 +08005 * (C) 2010 by On-Waves
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +02006 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +010010 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020012 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * GNU Affero General Public License for more details.
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020018 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010019 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020021 *
22 */
23
24#include <unistd.h>
25#include <stdlib.h>
26#include <stdio.h>
27#include <string.h>
28#include <assert.h>
29
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010030#include <osmocom/core/talloc.h>
Neels Hofmeyr93bafb62017-01-13 03:12:08 +010031#include <osmocom/core/utils.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +020032#include <osmocom/msc/gsm_subscriber.h>
33#include <osmocom/msc/debug.h>
34#include <osmocom/msc/vlr.h>
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020035
36LLIST_HEAD(active_subscribers);
37void *tall_subscr_ctx;
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020038
Harald Welte2483f1b2016-06-19 18:06:02 +020039/* return static buffer with printable name of VLR subscriber */
40const char *vlr_subscr_name(struct vlr_subscr *vsub)
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020041{
Harald Welte2483f1b2016-06-19 18:06:02 +020042 static char buf[32];
43 if (!vsub)
Harald Welte7184bd02015-12-28 14:04:36 +010044 return "unknown";
Harald Welte2483f1b2016-06-19 18:06:02 +020045 if (vsub->msisdn[0])
46 snprintf(buf, sizeof(buf), "MSISDN:%s", vsub->msisdn);
47 else if (vsub->imsi[0])
48 snprintf(buf, sizeof(buf), "IMSI:%s", vsub->imsi);
49 else if (vsub->tmsi != GSM_RESERVED_TMSI)
50 snprintf(buf, sizeof(buf), "TMSI:0x%08x", vsub->tmsi);
51 else if (vsub->tmsi_new != GSM_RESERVED_TMSI)
52 snprintf(buf, sizeof(buf), "TMSI(new):0x%08x", vsub->tmsi_new);
53 else
54 return "unknown";
55 buf[sizeof(buf)-1] = '\0';
56 return buf;
Holger Hans Peter Freyther06109472010-06-30 12:56:41 +080057}
58
Harald Welte2483f1b2016-06-19 18:06:02 +020059const char *vlr_subscr_msisdn_or_name(struct vlr_subscr *vsub)
Holger Hans Peter Freyther857e5e62009-06-12 07:08:13 +020060{
Harald Welte2483f1b2016-06-19 18:06:02 +020061 if (!vsub || !vsub->msisdn[0])
62 return vlr_subscr_name(vsub);
63 return vsub->msisdn;
Holger Hans Peter Freytherf694d5f2010-12-22 14:31:34 +010064}