Harald Welte | 936f672 | 2016-05-03 18:51:18 +0200 | [diff] [blame] | 1 | /* (C) 2016 by Harald Welte <laforge@gnumonks.org> |
| 2 | * |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 20 | #include <signal.h> |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 21 | #include <errno.h> |
Max | ea8b0d4 | 2017-02-14 16:53:04 +0100 | [diff] [blame] | 22 | #include <stdbool.h> |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 23 | #include <getopt.h> |
| 24 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 25 | #include <osmocom/core/msgb.h> |
Max | 20ddfdb | 2019-02-18 13:12:27 +0100 | [diff] [blame] | 26 | #include <osmocom/core/stats.h> |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 27 | #include <osmocom/core/logging.h> |
| 28 | #include <osmocom/core/application.h> |
| 29 | #include <osmocom/gsm/gsup.h> |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 30 | #include <osmocom/vty/vty.h> |
| 31 | #include <osmocom/vty/command.h> |
| 32 | #include <osmocom/vty/telnet_interface.h> |
| 33 | #include <osmocom/vty/ports.h> |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 34 | #include <osmocom/ctrl/control_vty.h> |
Neels Hofmeyr | 5aeb438 | 2018-05-04 16:02:44 +0200 | [diff] [blame] | 35 | #include <osmocom/gsm/apn.h> |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 36 | #include <osmocom/gsm/gsm48_ie.h> |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 37 | #include <osmocom/gsm/gsm_utils.h> |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 38 | #include <osmocom/gsm/gsm23003.h> |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 39 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 40 | #include <osmocom/gsupclient/ipa_name.h> |
Neels Hofmeyr | 2f75803 | 2019-11-20 00:37:07 +0100 | [diff] [blame] | 41 | #include <osmocom/hlr/db.h> |
| 42 | #include <osmocom/hlr/hlr.h> |
| 43 | #include <osmocom/hlr/ctrl.h> |
| 44 | #include <osmocom/hlr/logging.h> |
| 45 | #include <osmocom/hlr/gsup_server.h> |
| 46 | #include <osmocom/hlr/gsup_router.h> |
| 47 | #include <osmocom/hlr/rand.h> |
Neels Hofmeyr | 2f75803 | 2019-11-20 00:37:07 +0100 | [diff] [blame] | 48 | #include <osmocom/hlr/hlr_vty.h> |
| 49 | #include <osmocom/hlr/hlr_ussd.h> |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 50 | #include <osmocom/hlr/lu_fsm.h> |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 51 | |
Harald Welte | d5807b8 | 2018-07-29 12:27:41 +0200 | [diff] [blame] | 52 | struct hlr *g_hlr; |
Oliver Smith | c5044cf | 2019-02-26 16:32:57 +0100 | [diff] [blame] | 53 | static void *hlr_ctx = NULL; |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 54 | static int quit = 0; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 55 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 56 | struct osmo_tdef g_hlr_tdefs[] = { |
| 57 | /* 4222 is also the OSMO_GSUP_PORT */ |
| 58 | { .T = -4222, .default_val = 30, .desc = "GSUP Update Location timeout" }, |
| 59 | {} |
| 60 | }; |
| 61 | |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 62 | /* Trigger 'Insert Subscriber Data' messages to all connected GSUP clients. |
| 63 | * |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 64 | * \param[in] subscr A subscriber we have new data to send for. |
| 65 | */ |
| 66 | void |
| 67 | osmo_hlr_subscriber_update_notify(struct hlr_subscriber *subscr) |
| 68 | { |
| 69 | struct osmo_gsup_conn *co; |
| 70 | |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 71 | if (g_hlr->gs == NULL) { |
| 72 | LOGP(DLGSUP, LOGL_DEBUG, |
| 73 | "IMSI %s: NOT Notifying peers of subscriber data change," |
| 74 | " there is no GSUP server\n", |
| 75 | subscr->imsi); |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 76 | return; |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 77 | } |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 78 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 79 | /* FIXME: send only to current vlr_number and sgsn_number */ |
| 80 | |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 81 | llist_for_each_entry(co, &g_hlr->gs->clients, list) { |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 82 | struct osmo_gsup_message gsup = { }; |
| 83 | uint8_t msisdn_enc[OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN]; |
| 84 | uint8_t apn[APN_MAXLEN]; |
| 85 | struct msgb *msg_out; |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 86 | uint8_t *peer; |
| 87 | int peer_len; |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 88 | size_t peer_strlen; |
| 89 | const char *peer_compare; |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 90 | enum osmo_gsup_cn_domain cn_domain; |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 91 | |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 92 | if (co->supports_ps) { |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 93 | cn_domain = OSMO_GSUP_CN_DOMAIN_PS; |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 94 | peer_compare = subscr->sgsn_number; |
| 95 | } else if (co->supports_cs) { |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 96 | cn_domain = OSMO_GSUP_CN_DOMAIN_CS; |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 97 | peer_compare = subscr->vlr_number; |
| 98 | } else { |
| 99 | /* We have not yet received a location update from this GSUP client.*/ |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 100 | continue; |
| 101 | } |
| 102 | |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 103 | peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); |
| 104 | if (peer_len < 0) { |
| 105 | LOGP(DLGSUP, LOGL_ERROR, |
| 106 | "IMSI='%s': cannot get peer name for connection %s:%u\n", subscr->imsi, |
| 107 | co && co->conn && co->conn->server? co->conn->server->addr : "unset", |
| 108 | co && co->conn && co->conn->server? co->conn->server->port : 0); |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | peer_strlen = strnlen((const char*)peer, peer_len); |
| 113 | if (strlen(peer_compare) != peer_strlen || strncmp(peer_compare, (const char *)peer, peer_len)) { |
| 114 | /* Mismatch. The subscriber is not subscribed with this GSUP client. */ |
| 115 | /* I hope peer is always nul terminated... */ |
| 116 | if (peer_strlen < peer_len) |
| 117 | LOGP(DLGSUP, LOGL_DEBUG, |
| 118 | "IMSI %s: subscriber change: skipping %s peer %s\n", |
| 119 | subscr->imsi, cn_domain == OSMO_GSUP_CN_DOMAIN_PS ? "PS" : "CS", |
| 120 | osmo_quote_str((char*)peer, -1)); |
| 121 | continue; |
| 122 | } |
| 123 | |
| 124 | LOGP(DLGSUP, LOGL_DEBUG, |
| 125 | "IMSI %s: subscriber change: notifying %s peer %s\n", |
| 126 | subscr->imsi, cn_domain == OSMO_GSUP_CN_DOMAIN_PS ? "PS" : "CS", |
| 127 | osmo_quote_str(peer_compare, -1)); |
| 128 | |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 129 | if (osmo_gsup_create_insert_subscriber_data_msg(&gsup, subscr->imsi, subscr->msisdn, msisdn_enc, |
| 130 | sizeof(msisdn_enc), apn, sizeof(apn), cn_domain) != 0) { |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 131 | LOGP(DLGSUP, LOGL_ERROR, |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 132 | "IMSI='%s': Cannot notify GSUP client; could not create gsup message " |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 133 | "for %s:%u\n", subscr->imsi, |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 134 | co && co->conn && co->conn->server? co->conn->server->addr : "unset", |
| 135 | co && co->conn && co->conn->server? co->conn->server->port : 0); |
| 136 | continue; |
| 137 | } |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 138 | |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 139 | /* Send ISD to MSC/SGSN */ |
Neels Hofmeyr | a7d0f87 | 2019-10-30 02:08:28 +0100 | [diff] [blame] | 140 | msg_out = osmo_gsup_msgb_alloc("GSUP ISD UPDATE"); |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 141 | if (msg_out == NULL) { |
Neels Hofmeyr | e66e525 | 2018-09-28 02:59:19 +0200 | [diff] [blame] | 142 | LOGP(DLGSUP, LOGL_ERROR, |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 143 | "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " |
| 144 | "for %s:%u\n", subscr->imsi, |
| 145 | co && co->conn && co->conn->server? co->conn->server->addr : "unset", |
| 146 | co && co->conn && co->conn->server? co->conn->server->port : 0); |
| 147 | continue; |
| 148 | } |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 149 | osmo_gsup_encode(msg_out, &gsup); |
Stefan Sperling | f83432c | 2018-05-03 14:26:59 +0200 | [diff] [blame] | 150 | |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 151 | if (osmo_gsup_addr_send(g_hlr->gs, peer, peer_len, msg_out) < 0) { |
| 152 | LOGP(DMAIN, LOGL_ERROR, |
| 153 | "IMSI='%s': Cannot notify GSUP client; send operation failed " |
| 154 | "for %s:%u\n", subscr->imsi, |
| 155 | co && co->conn && co->conn->server? co->conn->server->addr : "unset", |
| 156 | co && co->conn && co->conn->server? co->conn->server->port : 0); |
| 157 | continue; |
| 158 | } |
Stefan Sperling | f162252 | 2018-04-09 11:39:16 +0200 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 162 | static int generate_new_msisdn(char *msisdn, const char *imsi, unsigned int len) |
| 163 | { |
| 164 | int i, j, rc; |
| 165 | uint8_t rand_buf[GSM23003_MSISDN_MAX_DIGITS]; |
| 166 | |
| 167 | OSMO_ASSERT(len <= sizeof(rand_buf)); |
| 168 | |
| 169 | /* Generate a random unique MSISDN (with retry) */ |
| 170 | for (i = 0; i < 10; i++) { |
| 171 | /* Get a random number (with retry) */ |
| 172 | for (j = 0; j < 10; j++) { |
| 173 | rc = osmo_get_rand_id(rand_buf, len); |
| 174 | if (!rc) |
| 175 | break; |
| 176 | } |
| 177 | if (rc) { |
| 178 | LOGP(DMAIN, LOGL_ERROR, "IMSI='%s': Failed to generate new MSISDN, random number generator" |
| 179 | " failed (rc=%d)\n", imsi, rc); |
| 180 | return rc; |
| 181 | } |
| 182 | |
| 183 | /* Shift 0x00 ... 0xff range to 30 ... 39 (ASCII numbers) */ |
| 184 | for (j = 0; j < len; j++) |
| 185 | msisdn[j] = 48 + (rand_buf[j] % 10); |
| 186 | msisdn[j] = '\0'; |
| 187 | |
| 188 | /* Ensure there is no subscriber with such MSISDN */ |
| 189 | if (db_subscr_exists_by_msisdn(g_hlr->dbc, msisdn) == -ENOENT) |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | /* Failure */ |
| 194 | LOGP(DMAIN, LOGL_ERROR, "IMSI='%s': Failed to generate a new MSISDN, consider increasing " |
| 195 | "the length for the automatically assigned MSISDNs " |
| 196 | "(see 'subscriber-create-on-demand' command)\n", imsi); |
| 197 | return -1; |
| 198 | } |
| 199 | |
| 200 | static int subscr_create_on_demand(const char *imsi) |
| 201 | { |
| 202 | char msisdn[GSM23003_MSISDN_MAX_DIGITS + 1]; |
| 203 | int rc; |
| 204 | unsigned int rand_msisdn_len = g_hlr->subscr_create_on_demand_rand_msisdn_len; |
| 205 | |
| 206 | if (!g_hlr->subscr_create_on_demand) |
| 207 | return -1; |
| 208 | if (db_subscr_exists_by_imsi(g_hlr->dbc, imsi) == 0) |
| 209 | return -1; |
| 210 | if (rand_msisdn_len && generate_new_msisdn(msisdn, imsi, rand_msisdn_len) != 0) |
| 211 | return -1; |
| 212 | |
| 213 | LOGP(DMAIN, LOGL_INFO, "IMSI='%s': Creating subscriber on demand\n", imsi); |
| 214 | rc = db_subscr_create(g_hlr->dbc, imsi, g_hlr->subscr_create_on_demand_flags); |
| 215 | if (rc) { |
| 216 | LOGP(DMAIN, LOGL_ERROR, "Failed to create subscriber on demand (rc=%d): IMSI='%s'\n", rc, imsi); |
| 217 | return rc; |
| 218 | } |
| 219 | |
| 220 | if (!rand_msisdn_len) |
| 221 | return 0; |
| 222 | |
| 223 | /* Update MSISDN of the new (just allocated) subscriber */ |
| 224 | rc = db_subscr_update_msisdn_by_imsi(g_hlr->dbc, imsi, msisdn); |
| 225 | if (rc) { |
| 226 | LOGP(DMAIN, LOGL_ERROR, "IMSI='%s': Failed to assign MSISDN='%s' (rc=%d)\n", imsi, msisdn, rc); |
| 227 | return rc; |
| 228 | } |
| 229 | LOGP(DMAIN, LOGL_INFO, "IMSI='%s': Successfully assigned MSISDN='%s'\n", imsi, msisdn); |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 234 | /*! Update nam_cs/nam_ps in the db and trigger notifications to GSUP clients. |
| 235 | * \param[in,out] hlr Global hlr context. |
| 236 | * \param[in] subscr Subscriber from a fresh db_subscr_get_by_*() call. |
| 237 | * \param[in] nam_val True to enable CS/PS, false to disable. |
| 238 | * \param[in] is_ps True to enable/disable PS, false for CS. |
| 239 | * \returns 0 on success, ENOEXEC if there is no need to change, a negative |
| 240 | * value on error. |
| 241 | */ |
| 242 | int hlr_subscr_nam(struct hlr *hlr, struct hlr_subscriber *subscr, bool nam_val, bool is_ps) |
| 243 | { |
| 244 | int rc; |
| 245 | bool is_val = is_ps? subscr->nam_ps : subscr->nam_cs; |
| 246 | struct osmo_ipa_name vlr_name; |
| 247 | struct osmo_gsup_message gsup_del_data = { |
| 248 | .message_type = OSMO_GSUP_MSGT_DELETE_DATA_REQUEST, |
| 249 | }; |
| 250 | OSMO_STRLCPY_ARRAY(gsup_del_data.imsi, subscr->imsi); |
| 251 | |
| 252 | if (is_val == nam_val) { |
| 253 | LOGP(DAUC, LOGL_DEBUG, "IMSI-%s: Already has the requested value when asked to %s %s\n", |
| 254 | subscr->imsi, nam_val ? "enable" : "disable", is_ps ? "PS" : "CS"); |
| 255 | return ENOEXEC; |
| 256 | } |
| 257 | |
| 258 | rc = db_subscr_nam(hlr->dbc, subscr->imsi, nam_val, is_ps); |
| 259 | if (rc) |
| 260 | return rc > 0? -rc : rc; |
| 261 | |
| 262 | /* If we're disabling, send a notice out to the GSUP client that is |
| 263 | * responsible. Otherwise no need. */ |
| 264 | if (nam_val) |
| 265 | return 0; |
| 266 | |
| 267 | if (subscr->vlr_number && osmo_ipa_name_set_str(&vlr_name, subscr->vlr_number)) |
| 268 | osmo_gsup_enc_send_to_ipa_name(g_hlr->gs, &vlr_name, &gsup_del_data); |
| 269 | if (subscr->sgsn_number && osmo_ipa_name_set_str(&vlr_name, subscr->sgsn_number)) |
| 270 | osmo_gsup_enc_send_to_ipa_name(g_hlr->gs, &vlr_name, &gsup_del_data); |
| 271 | return 0; |
| 272 | } |
| 273 | |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 274 | /*********************************************************************** |
| 275 | * Send Auth Info handling |
| 276 | ***********************************************************************/ |
| 277 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 278 | /* process an incoming SAI request */ |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 279 | static int rx_send_auth_info(unsigned int auc_3g_ind, struct osmo_gsup_req *req) |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 280 | { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 281 | struct osmo_gsup_message gsup_out = { |
| 282 | .message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT, |
| 283 | }; |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 284 | bool separation_bit = false; |
Alexander Couzens | 81b92bb | 2020-01-07 19:05:13 +0100 | [diff] [blame] | 285 | int num_auth_vectors = OSMO_GSUP_MAX_NUM_AUTH_INFO; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 286 | int rc; |
| 287 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 288 | subscr_create_on_demand(req->gsup.imsi); |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 289 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 290 | if (req->gsup.current_rat_type == OSMO_RAT_EUTRAN_SGS) |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 291 | separation_bit = true; |
| 292 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 293 | if (req->gsup.num_auth_vectors > 0 && |
| 294 | req->gsup.num_auth_vectors <= OSMO_GSUP_MAX_NUM_AUTH_INFO) |
| 295 | num_auth_vectors = req->gsup.num_auth_vectors; |
Alexander Couzens | 81b92bb | 2020-01-07 19:05:13 +0100 | [diff] [blame] | 296 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 297 | rc = db_get_auc(g_hlr->dbc, req->gsup.imsi, auc_3g_ind, |
Neels Hofmeyr | cab2fcd | 2017-03-15 00:07:43 +0100 | [diff] [blame] | 298 | gsup_out.auth_vectors, |
Alexander Couzens | 81b92bb | 2020-01-07 19:05:13 +0100 | [diff] [blame] | 299 | num_auth_vectors, |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 300 | req->gsup.rand, req->gsup.auts, separation_bit); |
| 301 | |
Neels Hofmeyr | 671db90 | 2017-11-22 20:38:19 +0100 | [diff] [blame] | 302 | if (rc <= 0) { |
Neels Hofmeyr | 671db90 | 2017-11-22 20:38:19 +0100 | [diff] [blame] | 303 | switch (rc) { |
| 304 | case 0: |
Neels Hofmeyr | bd1dca0 | 2017-11-23 15:25:30 +0100 | [diff] [blame] | 305 | /* 0 means "0 tuples generated", which shouldn't happen. |
| 306 | * Treat the same as "no auth data". */ |
| 307 | case -ENOKEY: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 308 | osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN, |
| 309 | "IMSI known, but has no auth data;" |
| 310 | " Returning slightly inaccurate cause 'IMSI Unknown' via GSUP"); |
| 311 | return rc; |
Neels Hofmeyr | 33cbde9 | 2017-11-22 20:39:59 +0100 | [diff] [blame] | 312 | case -ENOENT: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 313 | osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN, "IMSI unknown"); |
| 314 | return rc; |
Neels Hofmeyr | 671db90 | 2017-11-22 20:38:19 +0100 | [diff] [blame] | 315 | default: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 316 | osmo_gsup_req_respond_err(req, GMM_CAUSE_NET_FAIL, "failure to look up IMSI in db"); |
| 317 | return rc; |
Neels Hofmeyr | 671db90 | 2017-11-22 20:38:19 +0100 | [diff] [blame] | 318 | } |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 319 | } |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 320 | gsup_out.num_auth_vectors = rc; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 321 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 322 | osmo_gsup_req_respond(req, &gsup_out, false, true); |
| 323 | return 0; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 324 | } |
| 325 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 326 | /*! Receive Update Location Request, creates new lu_operation */ |
| 327 | static int rx_upd_loc_req(struct osmo_gsup_conn *conn, struct osmo_gsup_req *req) |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 328 | { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 329 | switch (req->gsup.cn_domain) { |
Neels Hofmeyr | 6cee799 | 2018-09-28 02:53:22 +0200 | [diff] [blame] | 330 | case OSMO_GSUP_CN_DOMAIN_CS: |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 331 | conn->supports_cs = true; |
Neels Hofmeyr | 6cee799 | 2018-09-28 02:53:22 +0200 | [diff] [blame] | 332 | break; |
| 333 | default: |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 334 | /* The client didn't send a CN_DOMAIN IE; assume packet-switched in |
| 335 | * accordance with the GSUP spec in osmo-hlr's user manual (section |
| 336 | * 11.6.15 "CN Domain" says "if no CN Domain IE is present within |
| 337 | * a request, the PS Domain is assumed." */ |
Neels Hofmeyr | 6cee799 | 2018-09-28 02:53:22 +0200 | [diff] [blame] | 338 | case OSMO_GSUP_CN_DOMAIN_PS: |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 339 | conn->supports_ps = true; |
Neels Hofmeyr | 6cee799 | 2018-09-28 02:53:22 +0200 | [diff] [blame] | 340 | break; |
Stefan Sperling | 93c5b10 | 2018-04-10 19:26:14 +0200 | [diff] [blame] | 341 | } |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 342 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 343 | subscr_create_on_demand(req->gsup.imsi); |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 344 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 345 | lu_rx_gsup(req); |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 346 | return 0; |
| 347 | } |
| 348 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 349 | static int rx_purge_ms_req(struct osmo_gsup_req *req) |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 350 | { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 351 | bool is_ps = (req->gsup.cn_domain != OSMO_GSUP_CN_DOMAIN_CS); |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 352 | int rc; |
| 353 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 354 | LOG_GSUP_REQ_CAT(req, DAUC, LOGL_INFO, "Purge MS (%s)\n", is_ps ? "PS" : "CS"); |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 355 | |
| 356 | /* FIXME: check if the VLR that sends the purge is the same that |
| 357 | * we have on record. Only update if yes */ |
| 358 | |
| 359 | /* Perform the actual update of the DB */ |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 360 | rc = db_subscr_purge(g_hlr->dbc, req->gsup.imsi, true, is_ps); |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 361 | |
Harald Welte | 3f2a9a2 | 2018-03-01 23:35:35 +0100 | [diff] [blame] | 362 | if (rc == 0) |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 363 | osmo_gsup_req_respond_msgt(req, OSMO_GSUP_MSGT_PURGE_MS_RESULT, true); |
| 364 | else if (rc == -ENOENT) |
| 365 | osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN, "IMSI unknown"); |
| 366 | else |
| 367 | osmo_gsup_req_respond_err(req, GMM_CAUSE_NET_FAIL, "db error"); |
| 368 | return rc; |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 369 | } |
| 370 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 371 | static int rx_check_imei_req(struct osmo_gsup_req *req) |
Harald Welte | a1d3b04 | 2018-06-11 20:28:35 +0200 | [diff] [blame] | 372 | { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 373 | struct osmo_gsup_message gsup_reply; |
Oliver Smith | 103c11b | 2019-06-06 11:57:05 +0200 | [diff] [blame] | 374 | char imei[GSM23003_IMEI_NUM_DIGITS_NO_CHK+1] = {0}; |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 375 | const struct osmo_gsup_message *gsup = &req->gsup; |
Oliver Smith | 103c11b | 2019-06-06 11:57:05 +0200 | [diff] [blame] | 376 | int rc; |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 377 | |
Oliver Smith | 103c11b | 2019-06-06 11:57:05 +0200 | [diff] [blame] | 378 | /* Require IMEI */ |
| 379 | if (!gsup->imei_enc) { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 380 | osmo_gsup_req_respond_err(req, GMM_CAUSE_INV_MAND_INFO, "missing IMEI"); |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 381 | return -1; |
| 382 | } |
| 383 | |
Oliver Smith | 103c11b | 2019-06-06 11:57:05 +0200 | [diff] [blame] | 384 | /* Decode IMEI (fails if IMEI is too long) */ |
| 385 | rc = gsm48_decode_bcd_number2(imei, sizeof(imei), gsup->imei_enc, gsup->imei_enc_len, 0); |
| 386 | if (rc < 0) { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 387 | osmo_gsup_req_respond_err(req, GMM_CAUSE_INV_MAND_INFO, |
| 388 | "failed to decode IMEI %s (rc: %d)", |
| 389 | osmo_hexdump_c(OTC_SELECT, gsup->imei_enc, gsup->imei_enc_len), |
| 390 | rc); |
Oliver Smith | 103c11b | 2019-06-06 11:57:05 +0200 | [diff] [blame] | 391 | return -1; |
| 392 | } |
| 393 | |
| 394 | /* Check if IMEI is too short */ |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 395 | if (!osmo_imei_str_valid(imei, false)) { |
| 396 | osmo_gsup_req_respond_err(req, GMM_CAUSE_INV_MAND_INFO, |
| 397 | "invalid IMEI: %s", osmo_quote_str_c(OTC_SELECT, imei, -1)); |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 398 | return -1; |
| 399 | } |
| 400 | |
Oliver Smith | c7f1787 | 2019-03-04 15:10:44 +0100 | [diff] [blame] | 401 | subscr_create_on_demand(gsup->imsi); |
| 402 | |
Oliver Smith | 851814a | 2019-01-11 15:30:21 +0100 | [diff] [blame] | 403 | /* Save in DB if desired */ |
| 404 | if (g_hlr->store_imei) { |
| 405 | LOGP(DAUC, LOGL_DEBUG, "IMSI='%s': storing IMEI = %s\n", gsup->imsi, imei); |
| 406 | if (db_subscr_update_imei_by_imsi(g_hlr->dbc, gsup->imsi, imei) < 0) { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 407 | osmo_gsup_req_respond_err(req, GMM_CAUSE_INV_MAND_INFO, "Failed to store IMEI in HLR db"); |
Oliver Smith | 851814a | 2019-01-11 15:30:21 +0100 | [diff] [blame] | 408 | return -1; |
| 409 | } |
| 410 | } else { |
| 411 | /* Check if subscriber exists and print IMEI */ |
| 412 | LOGP(DMAIN, LOGL_INFO, "IMSI='%s': has IMEI = %s (consider setting 'store-imei')\n", gsup->imsi, imei); |
| 413 | struct hlr_subscriber subscr; |
| 414 | if (db_subscr_get_by_imsi(g_hlr->dbc, gsup->imsi, &subscr) < 0) { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 415 | osmo_gsup_req_respond_err(req, GMM_CAUSE_INV_MAND_INFO, "IMSI unknown"); |
Oliver Smith | 851814a | 2019-01-11 15:30:21 +0100 | [diff] [blame] | 416 | return -1; |
| 417 | } |
| 418 | } |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 419 | |
| 420 | /* Accept all IMEIs */ |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 421 | gsup_reply = (struct osmo_gsup_message){ |
| 422 | .message_type = OSMO_GSUP_MSGT_CHECK_IMEI_RESULT, |
| 423 | .imei_result = OSMO_GSUP_IMEI_RESULT_ACK, |
| 424 | }; |
| 425 | return osmo_gsup_req_respond(req, &gsup_reply, false, true); |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 426 | } |
| 427 | |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 428 | static char namebuf[255]; |
| 429 | #define LOGP_GSUP_FWD(gsup, level, fmt, args ...) \ |
| 430 | LOGP(DMAIN, level, "Forward %s (class=%s, IMSI=%s, %s->%s): " fmt, \ |
Neels Hofmeyr | fbe4929 | 2020-01-09 18:35:03 +0100 | [diff] [blame] | 431 | osmo_gsup_message_type_name((gsup)->message_type), \ |
| 432 | osmo_gsup_message_class_name((gsup)->message_class), \ |
| 433 | (gsup)->imsi, \ |
| 434 | osmo_quote_str((const char *)(gsup)->source_name, (gsup)->source_name_len), \ |
| 435 | osmo_quote_str_buf2(namebuf, sizeof(namebuf), (const char *)(gsup)->destination_name, (gsup)->destination_name_len), \ |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 436 | ## args) |
| 437 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 438 | static int read_cb_forward(struct osmo_gsup_req *req) |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 439 | { |
| 440 | int ret = -EINVAL; |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 441 | const struct osmo_gsup_message *gsup = &req->gsup; |
| 442 | struct osmo_gsup_message gsup_err; |
| 443 | struct msgb *forward_msg; |
| 444 | struct osmo_ipa_name destination_name; |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 445 | |
| 446 | /* Check for routing IEs */ |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 447 | if (!req->gsup.source_name || !req->gsup.source_name_len |
| 448 | || !req->gsup.destination_name || !req->gsup.destination_name_len) { |
| 449 | LOGP_GSUP_FWD(&req->gsup, LOGL_ERROR, "missing routing IEs\n"); |
| 450 | goto routing_error; |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 451 | } |
| 452 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 453 | if (osmo_ipa_name_set(&destination_name, req->gsup.destination_name, req->gsup.destination_name_len)) { |
| 454 | LOGP_GSUP_FWD(&req->gsup, LOGL_ERROR, "invalid destination name\n"); |
| 455 | goto routing_error; |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 456 | } |
| 457 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 458 | LOG_GSUP_REQ(req, LOGL_INFO, "Forwarding to %s\n", osmo_ipa_name_to_str(&destination_name)); |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 459 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 460 | /* Forward message without re-encoding (so we don't remove unknown IEs). |
| 461 | * Copy GSUP part to forward, removing incoming IPA header to be able to prepend an outgoing IPA header */ |
| 462 | forward_msg = osmo_gsup_msgb_alloc("GSUP forward"); |
| 463 | forward_msg->l2h = msgb_put(forward_msg, msgb_l2len(req->msg)); |
| 464 | memcpy(forward_msg->l2h, msgb_l2(req->msg), msgb_l2len(req->msg)); |
| 465 | ret = osmo_gsup_send_to_ipa_name(g_hlr->gs, &destination_name, forward_msg); |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 466 | if (ret) { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 467 | LOGP_GSUP_FWD(gsup, LOGL_ERROR, "%s (rc=%d)\n", |
| 468 | ret == -ENODEV ? "destination not connected" : "unknown error", |
| 469 | ret); |
| 470 | goto routing_error; |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 471 | } |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 472 | osmo_gsup_req_free(req); |
| 473 | return 0; |
| 474 | |
| 475 | routing_error: |
| 476 | gsup_err = (struct osmo_gsup_message){ |
| 477 | .message_type = OSMO_GSUP_MSGT_ROUTING_ERROR, |
| 478 | .source_name = gsup->destination_name, |
| 479 | .source_name_len = gsup->destination_name_len, |
| 480 | }; |
| 481 | osmo_gsup_req_respond(req, &gsup_err, true, true); |
| 482 | return -1; |
Oliver Smith | 28f0af8 | 2019-02-22 11:46:33 +0100 | [diff] [blame] | 483 | } |
| 484 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 485 | static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg) |
| 486 | { |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 487 | struct osmo_gsup_req *req = osmo_gsup_conn_rx(conn, msg); |
| 488 | if (!req) |
Vadim Yanitskiy | d9724f4 | 2019-05-07 21:05:18 +0700 | [diff] [blame] | 489 | return -EINVAL; |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 490 | |
| 491 | /* If the GSUP recipient is other than this HLR, forward. */ |
| 492 | if (req->gsup.destination_name_len) { |
| 493 | struct osmo_ipa_name destination_name; |
| 494 | struct osmo_ipa_name my_name; |
| 495 | osmo_ipa_name_set_str(&my_name, g_hlr->gsup_unit_name.serno); |
| 496 | if (!osmo_ipa_name_set(&destination_name, req->gsup.destination_name, req->gsup.destination_name_len) |
| 497 | && osmo_ipa_name_cmp(&destination_name, &my_name)) { |
| 498 | return read_cb_forward(req); |
| 499 | } |
Vadim Yanitskiy | c69a18b | 2019-05-07 20:53:54 +0700 | [diff] [blame] | 500 | } |
| 501 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 502 | switch (req->gsup.message_type) { |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 503 | /* requests sent to us */ |
| 504 | case OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 505 | rx_send_auth_info(conn->auc_3g_ind, req); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 506 | break; |
| 507 | case OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 508 | rx_upd_loc_req(conn, req); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 509 | break; |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 510 | case OSMO_GSUP_MSGT_PURGE_MS_REQUEST: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 511 | rx_purge_ms_req(req); |
Harald Welte | b18f0e0 | 2016-05-05 21:03:03 +0200 | [diff] [blame] | 512 | break; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 513 | /* responses to requests sent by us */ |
Max | 9cacb6f | 2017-02-20 17:22:56 +0100 | [diff] [blame] | 514 | case OSMO_GSUP_MSGT_DELETE_DATA_ERROR: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 515 | LOG_GSUP_REQ(req, LOGL_ERROR, "Peer responds with: Error while deleting subscriber data\n"); |
| 516 | osmo_gsup_req_free(req); |
Max | 9cacb6f | 2017-02-20 17:22:56 +0100 | [diff] [blame] | 517 | break; |
| 518 | case OSMO_GSUP_MSGT_DELETE_DATA_RESULT: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 519 | LOG_GSUP_REQ(req, LOGL_DEBUG, "Peer responds with: Subscriber data deleted\n"); |
| 520 | osmo_gsup_req_free(req); |
Max | 9cacb6f | 2017-02-20 17:22:56 +0100 | [diff] [blame] | 521 | break; |
Harald Welte | bb77939 | 2018-06-16 20:21:10 +0200 | [diff] [blame] | 522 | case OSMO_GSUP_MSGT_PROC_SS_REQUEST: |
| 523 | case OSMO_GSUP_MSGT_PROC_SS_RESULT: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 524 | rx_proc_ss_req(req); |
Harald Welte | bb77939 | 2018-06-16 20:21:10 +0200 | [diff] [blame] | 525 | break; |
| 526 | case OSMO_GSUP_MSGT_PROC_SS_ERROR: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 527 | rx_proc_ss_error(req); |
Harald Welte | bb77939 | 2018-06-16 20:21:10 +0200 | [diff] [blame] | 528 | break; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 529 | case OSMO_GSUP_MSGT_INSERT_DATA_ERROR: |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 530 | case OSMO_GSUP_MSGT_INSERT_DATA_RESULT: |
Harald Welte | e687be5 | 2016-05-03 18:49:27 +0200 | [diff] [blame] | 531 | case OSMO_GSUP_MSGT_LOCATION_CANCEL_ERROR: |
| 532 | case OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 533 | lu_rx_gsup(req); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 534 | break; |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 535 | case OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST: |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 536 | rx_check_imei_req(req); |
Oliver Smith | 783ac81 | 2018-12-17 11:34:51 +0100 | [diff] [blame] | 537 | break; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 538 | default: |
Max | aa0fefd | 2017-02-16 12:25:22 +0100 | [diff] [blame] | 539 | LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n", |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 540 | osmo_gsup_message_type_name(req->gsup.message_type)); |
| 541 | osmo_gsup_req_free(req); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 542 | break; |
| 543 | } |
| 544 | return 0; |
| 545 | } |
| 546 | |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 547 | static void print_usage() |
| 548 | { |
| 549 | printf("Usage: osmo-hlr\n"); |
| 550 | } |
| 551 | |
| 552 | static void print_help() |
| 553 | { |
| 554 | printf(" -h --help This text.\n"); |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 555 | printf(" -c --config-file filename The config file to use.\n"); |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 556 | printf(" -l --database db-name The database to use.\n"); |
| 557 | printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM Enable debugging.\n"); |
| 558 | printf(" -D --daemonize Fork the process into a background daemon.\n"); |
| 559 | printf(" -s --disable-color Do not print ANSI colors in the log\n"); |
| 560 | printf(" -T --timestamp Prefix every log line with a timestamp.\n"); |
| 561 | printf(" -e --log-level number Set a global loglevel.\n"); |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 562 | printf(" -U --db-upgrade Allow HLR database schema upgrades.\n"); |
Neels Hofmeyr | c3d4032 | 2019-10-31 01:39:05 +0100 | [diff] [blame] | 563 | printf(" -C --db-check Quit after opening (and upgrading) the database.\n"); |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 564 | printf(" -V --version Print the version of OsmoHLR.\n"); |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | static struct { |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 568 | const char *config_file; |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 569 | const char *db_file; |
| 570 | bool daemonize; |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 571 | bool db_upgrade; |
Neels Hofmeyr | c3d4032 | 2019-10-31 01:39:05 +0100 | [diff] [blame] | 572 | bool db_check; |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 573 | } cmdline_opts = { |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 574 | .config_file = "osmo-hlr.cfg", |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 575 | .db_file = NULL, |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 576 | .daemonize = false, |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 577 | .db_upgrade = false, |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 578 | }; |
| 579 | |
| 580 | static void handle_options(int argc, char **argv) |
| 581 | { |
| 582 | while (1) { |
| 583 | int option_index = 0, c; |
| 584 | static struct option long_options[] = { |
| 585 | {"help", 0, 0, 'h'}, |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 586 | {"config-file", 1, 0, 'c'}, |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 587 | {"database", 1, 0, 'l'}, |
| 588 | {"debug", 1, 0, 'd'}, |
| 589 | {"daemonize", 0, 0, 'D'}, |
| 590 | {"disable-color", 0, 0, 's'}, |
| 591 | {"log-level", 1, 0, 'e'}, |
| 592 | {"timestamp", 0, 0, 'T'}, |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 593 | {"db-upgrade", 0, 0, 'U' }, |
Neels Hofmeyr | c3d4032 | 2019-10-31 01:39:05 +0100 | [diff] [blame] | 594 | {"db-check", 0, 0, 'C' }, |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 595 | {"version", 0, 0, 'V' }, |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 596 | {0, 0, 0, 0} |
| 597 | }; |
| 598 | |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 599 | c = getopt_long(argc, argv, "hc:l:d:Dse:TUV", |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 600 | long_options, &option_index); |
| 601 | if (c == -1) |
| 602 | break; |
| 603 | |
| 604 | switch (c) { |
| 605 | case 'h': |
| 606 | print_usage(); |
| 607 | print_help(); |
| 608 | exit(0); |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 609 | case 'c': |
| 610 | cmdline_opts.config_file = optarg; |
| 611 | break; |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 612 | case 'l': |
| 613 | cmdline_opts.db_file = optarg; |
| 614 | break; |
| 615 | case 'd': |
| 616 | log_parse_category_mask(osmo_stderr_target, optarg); |
| 617 | break; |
| 618 | case 'D': |
| 619 | cmdline_opts.daemonize = 1; |
| 620 | break; |
| 621 | case 's': |
| 622 | log_set_use_color(osmo_stderr_target, 0); |
| 623 | break; |
| 624 | case 'e': |
| 625 | log_set_log_level(osmo_stderr_target, atoi(optarg)); |
| 626 | break; |
| 627 | case 'T': |
| 628 | log_set_print_timestamp(osmo_stderr_target, 1); |
| 629 | break; |
Stefan Sperling | 8f3a7cc | 2018-11-27 12:10:45 +0100 | [diff] [blame] | 630 | case 'U': |
| 631 | cmdline_opts.db_upgrade = true; |
| 632 | break; |
Neels Hofmeyr | c3d4032 | 2019-10-31 01:39:05 +0100 | [diff] [blame] | 633 | case 'C': |
| 634 | cmdline_opts.db_check = true; |
| 635 | break; |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 636 | case 'V': |
| 637 | print_version(1); |
| 638 | exit(0); |
| 639 | break; |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 640 | default: |
| 641 | /* catch unknown options *as well as* missing arguments. */ |
| 642 | fprintf(stderr, "Error in command line options. Exiting.\n"); |
| 643 | exit(-1); |
| 644 | break; |
| 645 | } |
| 646 | } |
Harald Welte | 80dc9ae | 2019-12-03 22:16:39 +0100 | [diff] [blame] | 647 | |
| 648 | if (argc > optind) { |
| 649 | fprintf(stderr, "Unsupported positional arguments on command line\n"); |
| 650 | exit(2); |
| 651 | } |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 652 | } |
| 653 | |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 654 | static void signal_hdlr(int signal) |
| 655 | { |
| 656 | switch (signal) { |
Vadim Yanitskiy | ee7c0cb | 2019-03-19 18:10:51 +0700 | [diff] [blame] | 657 | case SIGTERM: |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 658 | case SIGINT: |
Vadim Yanitskiy | ee7c0cb | 2019-03-19 18:10:51 +0700 | [diff] [blame] | 659 | LOGP(DMAIN, LOGL_NOTICE, "Terminating due to signal=%d\n", signal); |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 660 | quit++; |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 661 | break; |
| 662 | case SIGUSR1: |
| 663 | LOGP(DMAIN, LOGL_DEBUG, "Talloc Report due to SIGUSR1\n"); |
Neels Hofmeyr | ca43e30 | 2017-01-30 13:18:23 +0100 | [diff] [blame] | 664 | talloc_report_full(hlr_ctx, stderr); |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 665 | break; |
| 666 | } |
| 667 | } |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 668 | |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 669 | static const char vlr_copyright[] = |
| 670 | "Copyright (C) 2016, 2017 by Harald Welte, sysmocom s.f.m.c. GmbH\r\n" |
| 671 | "License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n" |
| 672 | "This is free software: you are free to change and redistribute it.\r\n" |
| 673 | "There is NO WARRANTY, to the extent permitted by law.\r\n"; |
| 674 | |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 675 | static struct vty_app_info vty_info = { |
| 676 | .name = "OsmoHLR", |
| 677 | .version = PACKAGE_VERSION, |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 678 | .copyright = vlr_copyright, |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 679 | .is_config_node = hlr_vty_is_config_node, |
Pau Espin Pedrol | ce9bc40 | 2017-05-31 13:19:22 +0200 | [diff] [blame] | 680 | .go_parent_cb = hlr_vty_go_parent, |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 681 | }; |
| 682 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 683 | int main(int argc, char **argv) |
| 684 | { |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 685 | int rc; |
| 686 | |
Vadim Yanitskiy | 9fdb854 | 2018-07-30 03:09:22 +0700 | [diff] [blame] | 687 | /* Track the use of talloc NULL memory contexts */ |
| 688 | talloc_enable_null_tracking(); |
| 689 | |
Neels Hofmeyr | ca43e30 | 2017-01-30 13:18:23 +0100 | [diff] [blame] | 690 | hlr_ctx = talloc_named_const(NULL, 1, "OsmoHLR"); |
| 691 | msgb_talloc_ctx_init(hlr_ctx, 0); |
Harald Welte | 7ee6e55 | 2018-02-14 00:52:05 +0100 | [diff] [blame] | 692 | vty_info.tall_ctx = hlr_ctx; |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 693 | |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 694 | g_hlr = talloc_zero(hlr_ctx, struct hlr); |
Harald Welte | 4956ae1 | 2018-06-15 22:04:28 +0200 | [diff] [blame] | 695 | INIT_LLIST_HEAD(&g_hlr->euse_list); |
Harald Welte | bb77939 | 2018-06-16 20:21:10 +0200 | [diff] [blame] | 696 | INIT_LLIST_HEAD(&g_hlr->ss_sessions); |
Harald Welte | dab544e | 2018-07-29 16:14:48 +0200 | [diff] [blame] | 697 | INIT_LLIST_HEAD(&g_hlr->ussd_routes); |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 698 | g_hlr->db_file_path = talloc_strdup(g_hlr, HLR_DEFAULT_DB_FILE_PATH); |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 699 | |
Vadim Yanitskiy | d157a56 | 2018-12-01 00:03:39 +0700 | [diff] [blame] | 700 | /* Init default (call independent) SS session guard timeout value */ |
| 701 | g_hlr->ncss_guard_timeout = NCSS_GUARD_TIMEOUT_DEFAULT; |
| 702 | |
Pau Espin Pedrol | 5153031 | 2018-04-17 15:07:06 +0200 | [diff] [blame] | 703 | rc = osmo_init_logging2(hlr_ctx, &hlr_log_info); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 704 | if (rc < 0) { |
| 705 | fprintf(stderr, "Error initializing logging\n"); |
| 706 | exit(1); |
| 707 | } |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 708 | |
Max | 20ddfdb | 2019-02-18 13:12:27 +0100 | [diff] [blame] | 709 | osmo_stats_init(hlr_ctx); |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 710 | vty_init(&vty_info); |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 711 | ctrl_vty_init(hlr_ctx); |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 712 | handle_options(argc, argv); |
Pau Espin Pedrol | e49391b | 2019-08-05 15:57:10 +0200 | [diff] [blame] | 713 | hlr_vty_init(); |
Neels Hofmeyr | 7685a78 | 2017-01-30 23:30:26 +0100 | [diff] [blame] | 714 | |
| 715 | rc = vty_read_config_file(cmdline_opts.config_file, NULL); |
| 716 | if (rc < 0) { |
| 717 | LOGP(DMAIN, LOGL_FATAL, |
| 718 | "Failed to parse the config file: '%s'\n", |
| 719 | cmdline_opts.config_file); |
| 720 | return rc; |
| 721 | } |
| 722 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 723 | LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); |
| 724 | |
| 725 | rc = rand_init(); |
| 726 | if (rc < 0) { |
| 727 | LOGP(DMAIN, LOGL_FATAL, "Error initializing random source\n"); |
| 728 | exit(1); |
| 729 | } |
| 730 | |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 731 | if (cmdline_opts.db_file) |
| 732 | osmo_talloc_replace_string(g_hlr, &g_hlr->db_file_path, cmdline_opts.db_file); |
| 733 | |
| 734 | g_hlr->dbc = db_open(hlr_ctx, g_hlr->db_file_path, true, cmdline_opts.db_upgrade); |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 735 | if (!g_hlr->dbc) { |
Neels Hofmeyr | 5857c59 | 2019-04-02 04:24:49 +0200 | [diff] [blame] | 736 | LOGP(DMAIN, LOGL_FATAL, "Error opening database %s\n", osmo_quote_str(g_hlr->db_file_path, -1)); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 737 | exit(1); |
| 738 | } |
| 739 | |
Neels Hofmeyr | c3d4032 | 2019-10-31 01:39:05 +0100 | [diff] [blame] | 740 | if (cmdline_opts.db_check) { |
| 741 | LOGP(DMAIN, LOGL_NOTICE, "Cmdline option --db-check: Database was opened successfully, quitting.\n"); |
| 742 | db_close(g_hlr->dbc); |
| 743 | log_fini(); |
| 744 | talloc_free(hlr_ctx); |
| 745 | talloc_free(tall_vty_ctx); |
| 746 | talloc_disable_null_tracking(); |
| 747 | exit(0); |
| 748 | } |
| 749 | |
| 750 | /* start telnet after reading config for vty_get_bind_addr() */ |
| 751 | rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), |
| 752 | OSMO_VTY_PORT_HLR); |
| 753 | if (rc < 0) |
| 754 | return rc; |
| 755 | |
| 756 | |
Neels Hofmeyr | 84201d3 | 2017-07-21 16:00:32 +0200 | [diff] [blame] | 757 | g_hlr->gs = osmo_gsup_server_create(hlr_ctx, g_hlr->gsup_bind_addr, OSMO_GSUP_PORT, |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 758 | read_cb, g_hlr); |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 759 | if (!g_hlr->gs) { |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 760 | LOGP(DMAIN, LOGL_FATAL, "Error starting GSUP server\n"); |
| 761 | exit(1); |
| 762 | } |
| 763 | |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 764 | g_hlr->ctrl_bind_addr = ctrl_vty_get_bind_addr(); |
Neels Hofmeyr | 234f9cb | 2017-10-24 17:23:04 +0200 | [diff] [blame] | 765 | g_hlr->ctrl = hlr_controlif_setup(g_hlr); |
Max | 372868b | 2017-03-02 12:12:00 +0100 | [diff] [blame] | 766 | |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 767 | osmo_init_ignore_signals(); |
| 768 | signal(SIGINT, &signal_hdlr); |
Vadim Yanitskiy | ee7c0cb | 2019-03-19 18:10:51 +0700 | [diff] [blame] | 769 | signal(SIGTERM, &signal_hdlr); |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 770 | signal(SIGUSR1, &signal_hdlr); |
| 771 | |
Neels Hofmeyr | 7f9491f | 2017-01-30 13:30:47 +0100 | [diff] [blame] | 772 | if (cmdline_opts.daemonize) { |
| 773 | rc = osmo_daemonize(); |
| 774 | if (rc < 0) { |
| 775 | perror("Error during daemonize"); |
| 776 | exit(1); |
| 777 | } |
| 778 | } |
Harald Welte | aabae9e | 2016-04-28 12:48:14 +0200 | [diff] [blame] | 779 | |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 780 | while (!quit) |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame^] | 781 | osmo_select_main_ctx(0); |
| 782 | |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 783 | |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 784 | osmo_gsup_server_destroy(g_hlr->gs); |
Max | d4bebbd | 2017-03-02 12:00:19 +0100 | [diff] [blame] | 785 | db_close(g_hlr->dbc); |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 786 | log_fini(); |
| 787 | |
Vadim Yanitskiy | 4793a7e | 2018-07-30 03:04:34 +0700 | [diff] [blame] | 788 | /** |
| 789 | * Report the heap state of root context, then free, |
| 790 | * so both ASAN and Valgrind are happy... |
| 791 | */ |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 792 | talloc_report_full(hlr_ctx, stderr); |
Vadim Yanitskiy | 4793a7e | 2018-07-30 03:04:34 +0700 | [diff] [blame] | 793 | talloc_free(hlr_ctx); |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 794 | |
Vadim Yanitskiy | 9fdb854 | 2018-07-30 03:09:22 +0700 | [diff] [blame] | 795 | /* FIXME: VTY code still uses NULL-context */ |
| 796 | talloc_free(tall_vty_ctx); |
| 797 | |
| 798 | /** |
| 799 | * Report the heap state of NULL context, then free, |
| 800 | * so both ASAN and Valgrind are happy... |
| 801 | */ |
| 802 | talloc_report_full(NULL, stderr); |
| 803 | talloc_disable_null_tracking(); |
| 804 | |
Vadim Yanitskiy | 527d934 | 2018-07-30 02:42:25 +0700 | [diff] [blame] | 805 | return 0; |
Harald Welte | e72cf55 | 2016-04-28 07:18:49 +0200 | [diff] [blame] | 806 | } |