Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 1 | /* The concept of a subscriber as seen by the BSC */ |
| 2 | |
| 3 | /* (C) 2008 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 66efcbc | 2010-06-30 09:22:31 +0800 | [diff] [blame] | 4 | * (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
Holger Hans Peter Freyther | 85531cc | 2010-10-06 20:37:09 +0800 | [diff] [blame] | 5 | * (C) 2010 by On-Waves |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 10 | * 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 Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 12 | * (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 Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 18 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 19 | * 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 Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 21 | * |
| 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 Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 30 | #include <osmocom/core/talloc.h> |
Neels Hofmeyr | 93bafb6 | 2017-01-13 03:12:08 +0100 | [diff] [blame] | 31 | #include <osmocom/core/utils.h> |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 32 | #include <openbsc/gsm_subscriber.h> |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 33 | #include <openbsc/debug.h> |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 34 | #include <openbsc/vlr.h> |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 35 | |
| 36 | LLIST_HEAD(active_subscribers); |
| 37 | void *tall_subscr_ctx; |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 38 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 39 | /* return static buffer with printable name of VLR subscriber */ |
| 40 | const char *vlr_subscr_name(struct vlr_subscr *vsub) |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 41 | { |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 42 | static char buf[32]; |
| 43 | if (!vsub) |
Harald Welte | 7184bd0 | 2015-12-28 14:04:36 +0100 | [diff] [blame] | 44 | return "unknown"; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 45 | 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 Freyther | 0610947 | 2010-06-30 12:56:41 +0800 | [diff] [blame] | 57 | } |
| 58 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 59 | const char *vlr_subscr_msisdn_or_name(struct vlr_subscr *vsub) |
Holger Hans Peter Freyther | 857e5e6 | 2009-06-12 07:08:13 +0200 | [diff] [blame] | 60 | { |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 61 | if (!vsub || !vsub->msisdn[0]) |
| 62 | return vlr_subscr_name(vsub); |
| 63 | return vsub->msisdn; |
Holger Hans Peter Freyther | f694d5f | 2010-12-22 14:31:34 +0100 | [diff] [blame] | 64 | } |