blob: 8231e8cd84774cd65182aaf0f6a3138914961a64 [file] [log] [blame]
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +01001/* MS subscriber data handling */
2
3/* (C) 2014 by sysmocom s.f.m.c. GmbH
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -04004 * (C) 2015 by Holger Hans Peter Freyther
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +01005 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include <openbsc/gsm_subscriber.h>
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010024#include <openbsc/gprs_gsup_client.h>
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010025
26#include <openbsc/sgsn.h>
27#include <openbsc/gprs_sgsn.h>
28#include <openbsc/gprs_gmm.h>
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +010029#include <openbsc/gprs_gsup_messages.h>
Jacob Erlbeck0e8add62014-12-17 14:03:35 +010030#include <openbsc/gprs_utils.h>
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010031
32#include <openbsc/debug.h>
33
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010034#include <netinet/in.h>
35#include <arpa/inet.h>
36
Jacob Erlbeck743dec42015-01-08 15:18:39 +010037#define SGSN_SUBSCR_MAX_RETRIES 3
38#define SGSN_SUBSCR_RETRY_INTERVAL 10
39
Jacob Erlbeck929acdf2015-01-27 13:47:24 +010040#define LOGGSUPP(level, gsup, fmt, args...) \
41 LOGP(DGPRS, level, "GSUP(%s) " fmt, \
42 (gsup)->imsi, \
43 ## args)
44
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010045extern void *tall_bsc_ctx;
46
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010047static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg);
48
49/* TODO: Some functions are specific to the SGSN, but this file is more general
50 * (it has gprs_* name). Either move these functions elsewhere, split them and
51 * move a part, or replace the gprs_ prefix by sgsn_. The applies to
52 * gprs_subscr_init, gsup_read_cb, and gprs_subscr_tx_gsup_message.
53 */
54
55int gprs_subscr_init(struct sgsn_instance *sgi)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010056{
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010057 const char *addr_str;
58
59 if (!sgi->cfg.gsup_server_addr.sin_addr.s_addr)
60 return 0;
61
62 addr_str = inet_ntoa(sgi->cfg.gsup_server_addr.sin_addr);
63
64 sgi->gsup_client = gprs_gsup_client_create(
65 addr_str, sgi->cfg.gsup_server_port,
66 &gsup_read_cb);
67
68 if (!sgi->gsup_client)
69 return -1;
70
71 return 1;
72}
73
74static int gsup_read_cb(struct gprs_gsup_client *gsupc, struct msgb *msg)
75{
76 int rc;
77
78 rc = gprs_subscr_rx_gsup_message(msg);
Jacob Erlbecke154d8b2014-12-19 19:15:55 +010079 msgb_free(msg);
Jacob Erlbeck39f040d2014-12-18 12:46:47 +010080 if (rc < 0)
81 return -1;
82
83 return rc;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +010084}
85
Jacob Erlbeck0f47b8f2015-01-06 16:32:41 +010086int gprs_subscr_purge(struct gsm_subscriber *subscr);
87
Jacob Erlbecka1e03732014-12-02 11:28:38 +010088static struct sgsn_subscriber_data *sgsn_subscriber_data_alloc(void *ctx)
89{
90 struct sgsn_subscriber_data *sdata;
Jacob Erlbeck7921ab12014-12-08 15:52:00 +010091 int idx;
Jacob Erlbecka1e03732014-12-02 11:28:38 +010092
93 sdata = talloc_zero(ctx, struct sgsn_subscriber_data);
94
Jacob Erlbeckd6267d12015-01-19 11:10:04 +010095 sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
96
Jacob Erlbeck7921ab12014-12-08 15:52:00 +010097 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
98 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
99
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100100 INIT_LLIST_HEAD(&sdata->pdp_list);
101
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100102 return sdata;
103}
104
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100105struct sgsn_subscriber_pdp_data* sgsn_subscriber_pdp_data_alloc(
106 struct sgsn_subscriber_data *sdata)
107{
108 struct sgsn_subscriber_pdp_data* pdata;
109
110 pdata = talloc_zero(sdata, struct sgsn_subscriber_pdp_data);
111
112 llist_add_tail(&pdata->list, &sdata->pdp_list);
113
114 return pdata;
115}
116
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100117struct gsm_subscriber *gprs_subscr_get_or_create(const char *imsi)
118{
119 struct gsm_subscriber *subscr;
120
121 subscr = subscr_get_or_create(NULL, imsi);
122 if (!subscr)
123 return NULL;
124
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100125 if (!subscr->sgsn_data)
126 subscr->sgsn_data = sgsn_subscriber_data_alloc(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100127 return subscr;
128}
129
130struct gsm_subscriber *gprs_subscr_get_by_imsi(const char *imsi)
131{
132 return subscr_active_by_imsi(NULL, imsi);
133}
134
Jacob Erlbeck3e4e58f2015-01-26 11:07:24 +0100135void gprs_subscr_cleanup(struct gsm_subscriber *subscr)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100136{
Jacob Erlbecka1e03732014-12-02 11:28:38 +0100137 if (subscr->sgsn_data->mm) {
138 subscr_put(subscr->sgsn_data->mm->subscr);
139 subscr->sgsn_data->mm->subscr = NULL;
140 subscr->sgsn_data->mm = NULL;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100141 }
142
Holger Hans Peter Freyther1d778fd2015-01-20 21:14:03 +0100143 if (subscr->flags & GPRS_SUBSCRIBER_ENABLE_PURGE) {
144 gprs_subscr_purge(subscr);
145 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck0f47b8f2015-01-06 16:32:41 +0100146 }
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100147}
148
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100149void gprs_subscr_cancel(struct gsm_subscriber *subscr)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100150{
151 subscr->authorized = 0;
152 subscr->flags |= GPRS_SUBSCRIBER_CANCELLED;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100153 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100154
155 gprs_subscr_update(subscr);
Jacob Erlbeck3e4e58f2015-01-26 11:07:24 +0100156 gprs_subscr_cleanup(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100157}
158
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100159static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
160 struct gprs_gsup_message *gsup_msg)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100161{
Jacob Erlbeck39f040d2014-12-18 12:46:47 +0100162 struct msgb *msg = gprs_gsup_msgb_alloc();
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100163
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100164 if (strlen(gsup_msg->imsi) == 0 && subscr)
165 strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100166
167 gprs_gsup_encode(msg, gsup_msg);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100168
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100169 LOGGSUBSCRP(LOGL_INFO, subscr,
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100170 "Sending GSUP, will send: %s\n", msgb_hexdump(msg));
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100171
Jacob Erlbeck39f040d2014-12-18 12:46:47 +0100172 if (!sgsn->gsup_client) {
173 msgb_free(msg);
174 return -ENOTSUP;
175 }
176
177 return gprs_gsup_client_send(sgsn->gsup_client, msg);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100178}
179
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100180static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
181 struct gprs_gsup_message *gsup_orig,
182 enum gsm48_gmm_cause cause)
183{
184 struct gprs_gsup_message gsup_reply = {0};
185
186 strncpy(gsup_reply.imsi, gsup_orig->imsi, sizeof(gsup_reply.imsi) - 1);
187 gsup_reply.cause = cause;
188 gsup_reply.message_type =
189 GPRS_GSUP_TO_MSGT_ERROR(gsup_orig->message_type);
190
191 return gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
192}
193
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100194static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr,
195 struct gprs_gsup_message *gsup_msg)
196{
197 unsigned idx;
198 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
199
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100200 LOGGSUBSCRP(LOGL_INFO, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400201 "Got SendAuthenticationInfoResult, num_auth_tuples = %zu\n",
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100202 gsup_msg->num_auth_tuples);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100203
204 if (gsup_msg->num_auth_tuples > 0) {
205 memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets));
206
207 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
208 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
209 }
210
211 for (idx = 0; idx < gsup_msg->num_auth_tuples; idx++) {
212 size_t key_seq = gsup_msg->auth_tuples[idx].key_seq;
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100213 LOGGSUBSCRP(LOGL_DEBUG, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400214 "Adding auth tuple, cksn = %zu\n", key_seq);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100215 if (key_seq >= ARRAY_SIZE(sdata->auth_triplets)) {
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100216 LOGGSUBSCRP(LOGL_NOTICE, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400217 "Skipping auth triplet with invalid cksn %zu\n",
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100218 key_seq);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100219 continue;
220 }
221 sdata->auth_triplets[key_seq] = gsup_msg->auth_tuples[idx];
222 }
223
224 sdata->auth_triplets_updated = 1;
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100225 sdata->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100226
227 gprs_subscr_update_auth_info(subscr);
228
229 return 0;
230}
231
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100232static int gprs_subscr_pdp_data_clear(struct gsm_subscriber *subscr)
233{
234 struct sgsn_subscriber_pdp_data *pdp, *pdp2;
235 int count = 0;
236
237 llist_for_each_entry_safe(pdp, pdp2, &subscr->sgsn_data->pdp_list, list) {
238 llist_del(&pdp->list);
239 talloc_free(pdp);
240 count += 1;
241 }
242
243 return count;
244}
245
246static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id(
247 struct gsm_subscriber *subscr, unsigned context_id)
248{
249 struct sgsn_subscriber_pdp_data *pdp;
250
251 llist_for_each_entry(pdp, &subscr->sgsn_data->pdp_list, list) {
252 if (pdp->context_id == context_id)
253 return pdp;
254 }
255
256 return NULL;
257}
258
259
260static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr,
261 struct gprs_gsup_message *gsup_msg)
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100262{
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -0400263 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100264 unsigned idx;
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100265 int rc;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100266
Holger Hans Peter Freyther9ba273d2015-04-23 09:53:53 -0400267 if (gsup_msg->msisdn_enc) {
268 if (gsup_msg->msisdn_enc_len > sizeof(sdata->msisdn)) {
269 LOGP(DGPRS, LOGL_ERROR, "MSISDN too long (%zu)\n",
270 gsup_msg->msisdn_enc_len);
271 sdata->msisdn_len = 0;
272 } else {
273 memcpy(sdata->msisdn, gsup_msg->msisdn_enc,
274 gsup_msg->msisdn_enc_len);
275 sdata->msisdn_len = gsup_msg->msisdn_enc_len;
276 }
277 }
278
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200279 if (gsup_msg->hlr_enc) {
280 if (gsup_msg->hlr_enc_len > sizeof(sdata->hlr)) {
281 LOGP(DGPRS, LOGL_ERROR, "HLR-Number too long (%zu)\n",
282 gsup_msg->hlr_enc_len);
283 sdata->hlr_len = 0;
284 } else {
285 memcpy(sdata->hlr, gsup_msg->hlr_enc,
286 gsup_msg->hlr_enc_len);
287 sdata->hlr_len = gsup_msg->hlr_enc_len;
288 }
289 }
290
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100291 if (gsup_msg->pdp_info_compl) {
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100292 rc = gprs_subscr_pdp_data_clear(subscr);
293 if (rc > 0)
294 LOGP(DGPRS, LOGL_INFO, "Cleared existing PDP info\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100295 }
296
297 for (idx = 0; idx < gsup_msg->num_pdp_infos; idx++) {
298 struct gprs_gsup_pdp_info *pdp_info = &gsup_msg->pdp_infos[idx];
299 size_t ctx_id = pdp_info->context_id;
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100300 struct sgsn_subscriber_pdp_data *pdp_data;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100301
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100302 if (pdp_info->apn_enc_len >= sizeof(pdp_data->apn_str)-1) {
303 LOGGSUBSCRP(LOGL_ERROR, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400304 "APN too long, context id = %zu, APN = %s\n",
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100305 ctx_id, osmo_hexdump(pdp_info->apn_enc,
306 pdp_info->apn_enc_len));
307 continue;
308 }
309
Holger Hans Peter Freyther8cedded2015-04-23 11:33:35 -0400310 if (pdp_info->qos_enc_len > sizeof(pdp_data->qos_subscribed)) {
311 LOGGSUBSCRP(LOGL_ERROR, subscr,
312 "QoS info too long (%zu)\n",
313 pdp_info->qos_enc_len);
314 continue;
315 }
316
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100317 LOGGSUBSCRP(LOGL_INFO, subscr,
Holger Hans Peter Freyther8e6ecc92015-04-23 11:55:23 -0400318 "Will set PDP info, context id = %zu, APN = %s\n",
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100319 ctx_id, osmo_hexdump(pdp_info->apn_enc, pdp_info->apn_enc_len));
320
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100321 /* Set PDP info [ctx_id] */
322 pdp_data = gprs_subscr_pdp_data_get_by_id(subscr, ctx_id);
323 if (!pdp_data) {
324 pdp_data = sgsn_subscriber_pdp_data_alloc(subscr->sgsn_data);
325 pdp_data->context_id = ctx_id;
326 }
327
328 OSMO_ASSERT(pdp_data != NULL);
329 pdp_data->pdp_type = pdp_info->pdp_type;
330 gprs_apn_to_str(pdp_data->apn_str,
331 pdp_info->apn_enc, pdp_info->apn_enc_len);
Holger Hans Peter Freyther8cedded2015-04-23 11:33:35 -0400332 memcpy(pdp_data->qos_subscribed, pdp_info->qos_enc, pdp_info->qos_enc_len);
333 pdp_data->qos_subscribed_len = pdp_info->qos_enc_len;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100334 }
Jacob Erlbeck0e8add62014-12-17 14:03:35 +0100335}
336
337static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr,
338 struct gprs_gsup_message *gsup_msg)
339{
340 gprs_subscr_gsup_insert_data(subscr, gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100341
342 subscr->authorized = 1;
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100343 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100344
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100345 subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE;
346
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100347 gprs_subscr_update(subscr);
348 return 0;
349}
350
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100351static int check_cause(int cause)
352{
353 switch (cause) {
354 case GMM_CAUSE_IMSI_UNKNOWN ... GMM_CAUSE_ILLEGAL_ME:
355 case GMM_CAUSE_GPRS_NOTALLOWED ... GMM_CAUSE_NO_GPRS_PLMN:
356 return EACCES;
357
358 case GMM_CAUSE_MSC_TEMP_NOTREACH ... GMM_CAUSE_CONGESTION:
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100359 return EHOSTUNREACH;
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100360
361 case GMM_CAUSE_SEM_INCORR_MSG ... GMM_CAUSE_PROTO_ERR_UNSPEC:
362 default:
363 return EINVAL;
364 }
365}
366
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100367static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr,
368 struct gprs_gsup_message *gsup_msg)
369{
370 unsigned idx;
371 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100372 int cause_err;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100373
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100374 cause_err = check_cause(gsup_msg->cause);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100375
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100376 LOGGSUBSCRP(LOGL_DEBUG, subscr,
377 "Send authentication info has failed with cause %d, "
378 "handled as: %s\n",
379 gsup_msg->cause, strerror(cause_err));
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100380
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100381 switch (cause_err) {
382 case EACCES:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100383 LOGGSUBSCRP(LOGL_NOTICE, subscr,
384 "GPRS send auth info req failed, access denied, "
385 "GMM cause = '%s' (%d)\n",
386 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
387 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100388 /* Clear auth tuples */
389 memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets));
390 for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
391 sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100392
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100393 subscr->authorized = 0;
394 sdata->error_cause = gsup_msg->cause;
395 gprs_subscr_update_auth_info(subscr);
396 break;
397
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100398 case EHOSTUNREACH:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100399 LOGGSUBSCRP(LOGL_NOTICE, subscr,
400 "GPRS send auth info req failed, GMM cause = '%s' (%d)\n",
401 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
402 gsup_msg->cause);
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100403
404 sdata->error_cause = gsup_msg->cause;
405 gprs_subscr_update_auth_info(subscr);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100406 break;
407
408 default:
409 case EINVAL:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100410 LOGGSUBSCRP(LOGL_ERROR, subscr,
411 "GSUP protocol remote error, GMM cause = '%s' (%d)\n",
412 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
413 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100414 break;
415 }
416
417 return -gsup_msg->cause;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100418}
419
420static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr,
421 struct gprs_gsup_message *gsup_msg)
422{
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100423 int cause_err;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100424
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100425 cause_err = check_cause(gsup_msg->cause);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100426
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100427 LOGGSUBSCRP(LOGL_DEBUG, subscr,
428 "Update location has failed with cause %d, handled as: %s\n",
429 gsup_msg->cause, strerror(cause_err));
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100430
431 switch (cause_err) {
432 case EACCES:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100433 LOGGSUBSCRP(LOGL_NOTICE, subscr,
434 "GPRS update location failed, access denied, "
435 "GMM cause = '%s' (%d)\n",
436 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
437 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100438
439 subscr->authorized = 0;
440 subscr->sgsn_data->error_cause = gsup_msg->cause;
441 gprs_subscr_update_auth_info(subscr);
442 break;
443
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100444 case EHOSTUNREACH:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100445 LOGGSUBSCRP(LOGL_NOTICE, subscr,
446 "GPRS update location failed, GMM cause = '%s' (%d)\n",
447 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
448 gsup_msg->cause);
Jacob Erlbeckf06fe292015-01-05 16:20:47 +0100449
450 subscr->sgsn_data->error_cause = gsup_msg->cause;
451 gprs_subscr_update_auth_info(subscr);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100452 break;
453
454 default:
455 case EINVAL:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100456 LOGGSUBSCRP(LOGL_ERROR, subscr,
457 "GSUP protocol remote error, GMM cause = '%s' (%d)\n",
458 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
459 gsup_msg->cause);
Jacob Erlbeck9aa99912015-01-05 18:38:41 +0100460 break;
461 }
462
463 return -gsup_msg->cause;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100464}
465
Jacob Erlbeck929acdf2015-01-27 13:47:24 +0100466static int gprs_subscr_handle_gsup_purge_no_subscr(
467 struct gprs_gsup_message *gsup_msg)
468{
469 if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
470 LOGGSUPP(LOGL_NOTICE, gsup_msg,
471 "Purge MS has failed with cause '%s' (%d)\n",
472 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
473 gsup_msg->cause);
474 return -gsup_msg->cause;
475 }
476
477 LOGGSUPP(LOGL_INFO, gsup_msg, "Completing purge MS\n");
478 return 0;
479}
480
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100481static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr,
482 struct gprs_gsup_message *gsup_msg)
483{
484 LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n");
485
486 /* Force silent cancellation */
Jacob Erlbeckd6267d12015-01-19 11:10:04 +0100487 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100488 gprs_subscr_cancel(subscr);
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100489
490 return 0;
491}
492
493static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr,
494 struct gprs_gsup_message *gsup_msg)
495{
496 LOGGSUBSCRP(LOGL_NOTICE, subscr,
497 "Purge MS has failed with cause '%s' (%d)\n",
498 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
499 gsup_msg->cause);
500
501 /* In GSM 09.02, 19.1.4.4, the text and the SDL diagram imply that
502 * the subscriber data is not removed if the request has failed. On the
503 * other hand, keeping the subscriber data in either error case
504 * (subscriber unknown, syntactical message error, connection error)
505 * doesn't seem to give any advantage, since the data will be restored
506 * on the next Attach Request anyway.
507 * This approach ensures, that the subscriber record will not stick if
508 * an error happens.
509 */
510
511 /* TODO: Check whether this behaviour is acceptable and either just
512 * remove this TODO-notice or change the implementation to not delete
513 * the subscriber data (eventually resetting the ENABLE_PURGE flag and
514 * restarting the expiry timer based on the cause).
515 *
516 * Subscriber Unknown: cancel subscr
517 * Temporary network problems: do nothing (handled by timer based retry)
518 * Message problems (syntax, nyi, ...): cancel subscr (retry won't help)
519 */
520
521 gprs_subscr_handle_gsup_purge_res(subscr, gsup_msg);
522
523 return -gsup_msg->cause;
524}
525
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100526static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr,
527 struct gprs_gsup_message *gsup_msg)
528{
529 struct gprs_gsup_message gsup_reply = {0};
Jacob Erlbeck5b512052015-04-07 17:49:48 +0200530 int is_update_procedure = !gsup_msg->cancel_type ||
531 gsup_msg->cancel_type == GPRS_GSUP_CANCEL_TYPE_UPDATE;
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100532
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +0100533 LOGGSUBSCRP(LOGL_INFO, subscr, "Cancelling MS subscriber (%s)\n",
534 is_update_procedure ?
535 "update procedure" : "subscription withdraw");
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100536
537 gsup_reply.message_type = GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT;
538 gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
539
Jacob Erlbeck8000e0e2015-01-27 14:56:40 +0100540 if (is_update_procedure)
541 subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
542 else
543 /* Since a withdraw cause is not specified, just abort the
544 * current attachment. The following re-attachment should then
545 * be rejected with a proper cause value.
546 */
547 subscr->sgsn_data->error_cause = GMM_CAUSE_IMPL_DETACHED;
548
Jacob Erlbeck37139e52015-01-23 13:52:55 +0100549 gprs_subscr_cancel(subscr);
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100550
551 return 0;
552}
553
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100554static int gprs_subscr_handle_unknown_imsi(struct gprs_gsup_message *gsup_msg)
555{
556 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) {
557 gprs_subscr_tx_gsup_error_reply(NULL, gsup_msg,
558 GMM_CAUSE_IMSI_UNKNOWN);
559 LOGP(DGPRS, LOGL_NOTICE,
560 "Unknown IMSI %s, discarding GSUP request "
561 "of type 0x%02x\n",
562 gsup_msg->imsi, gsup_msg->message_type);
563 } else if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
564 LOGP(DGPRS, LOGL_NOTICE,
565 "Unknown IMSI %s, discarding GSUP error "
566 "of type 0x%02x, cause '%s' (%d)\n",
567 gsup_msg->imsi, gsup_msg->message_type,
568 get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
569 gsup_msg->cause);
570 } else {
571 LOGP(DGPRS, LOGL_NOTICE,
572 "Unknown IMSI %s, discarding GSUP response "
573 "of type 0x%02x\n",
574 gsup_msg->imsi, gsup_msg->message_type);
575 }
576
577 return -GMM_CAUSE_IMSI_UNKNOWN;
578}
579
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100580int gprs_subscr_rx_gsup_message(struct msgb *msg)
581{
582 uint8_t *data = msgb_l2(msg);
583 size_t data_len = msgb_l2len(msg);
584 int rc = 0;
585
586 struct gprs_gsup_message gsup_msg = {0};
587 struct gsm_subscriber *subscr;
588
589 rc = gprs_gsup_decode(data, data_len, &gsup_msg);
590 if (rc < 0) {
591 LOGP(DGPRS, LOGL_ERROR,
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100592 "decoding GSUP message fails with error '%s' (%d)\n",
593 get_value_string(gsm48_gmm_cause_names, -rc), -rc);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100594 return rc;
595 }
596
Jacob Erlbeck07f6e362015-01-29 14:00:28 +0100597 if (!gsup_msg.imsi[0]) {
598 LOGP(DGPRS, LOGL_ERROR, "Missing IMSI in GSUP message\n");
599
600 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
601 gprs_subscr_tx_gsup_error_reply(NULL, &gsup_msg,
602 GMM_CAUSE_INV_MAND_INFO);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100603 return -GMM_CAUSE_INV_MAND_INFO;
Jacob Erlbeck07f6e362015-01-29 14:00:28 +0100604 }
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100605
Jacob Erlbeck9ff82892015-01-29 14:17:51 +0100606 if (!gsup_msg.cause && GPRS_GSUP_IS_MSGT_ERROR(gsup_msg.message_type))
607 gsup_msg.cause = GMM_CAUSE_NET_FAIL;
608
Jacob Erlbeck4dedb272015-01-15 17:50:16 +0100609 subscr = gprs_subscr_get_by_imsi(gsup_msg.imsi);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100610
Jacob Erlbeck929acdf2015-01-27 13:47:24 +0100611 if (!subscr) {
612 switch (gsup_msg.message_type) {
613 case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
614 case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
615 return gprs_subscr_handle_gsup_purge_no_subscr(&gsup_msg);
616 default:
617 return gprs_subscr_handle_unknown_imsi(&gsup_msg);
618 }
619 }
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100620
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100621 LOGGSUBSCRP(LOGL_INFO, subscr,
622 "Received GSUP message of type 0x%02x\n", gsup_msg.message_type);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100623
624 switch (gsup_msg.message_type) {
625 case GPRS_GSUP_MSGT_LOCATION_CANCEL_REQUEST:
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100626 rc = gprs_subscr_handle_loc_cancel_req(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100627 break;
628
629 case GPRS_GSUP_MSGT_SEND_AUTH_INFO_RESULT:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100630 rc = gprs_subscr_handle_gsup_auth_res(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100631 break;
632
633 case GPRS_GSUP_MSGT_SEND_AUTH_INFO_ERROR:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100634 rc = gprs_subscr_handle_gsup_auth_err(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100635 break;
636
637 case GPRS_GSUP_MSGT_UPDATE_LOCATION_RESULT:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100638 rc = gprs_subscr_handle_gsup_upd_loc_res(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100639 break;
640
641 case GPRS_GSUP_MSGT_UPDATE_LOCATION_ERROR:
Jacob Erlbeckbce20612015-01-05 18:57:32 +0100642 rc = gprs_subscr_handle_gsup_upd_loc_err(subscr, &gsup_msg);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100643 break;
644
645 case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100646 rc = gprs_subscr_handle_gsup_purge_err(subscr, &gsup_msg);
647 break;
648
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100649 case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100650 rc = gprs_subscr_handle_gsup_purge_res(subscr, &gsup_msg);
651 break;
652
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100653 case GPRS_GSUP_MSGT_INSERT_DATA_REQUEST:
654 case GPRS_GSUP_MSGT_DELETE_DATA_REQUEST:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100655 LOGGSUBSCRP(LOGL_ERROR, subscr,
656 "Rx GSUP message type %d not yet implemented\n",
657 gsup_msg.message_type);
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100658 gprs_subscr_tx_gsup_error_reply(subscr, &gsup_msg,
659 GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100660 rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
661 break;
662
663 default:
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100664 LOGGSUBSCRP(LOGL_ERROR, subscr,
665 "Rx GSUP message type %d not valid at SGSN\n",
666 gsup_msg.message_type);
Jacob Erlbeck9999fd92015-01-15 17:08:30 +0100667 if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
668 gprs_subscr_tx_gsup_error_reply(
669 subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
670 rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100671 break;
672 };
673
Jacob Erlbeck87c7ffc2015-01-08 15:29:01 +0100674 subscr_put(subscr);
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100675
676 return rc;
677}
678
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100679int gprs_subscr_purge(struct gsm_subscriber *subscr)
680{
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200681 struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100682 struct gprs_gsup_message gsup_msg = {0};
683
684 LOGGSUBSCRP(LOGL_INFO, subscr, "purging MS subscriber\n");
685
686 gsup_msg.message_type = GPRS_GSUP_MSGT_PURGE_MS_REQUEST;
Holger Hans Peter Freyther10c0f562015-05-17 20:58:40 +0200687
688 /* Provide the HLR number in case it is known */
689 gsup_msg.hlr_enc_len = sdata->hlr_len;
690 gsup_msg.hlr_enc = sdata->hlr;
691
Jacob Erlbeckca69b0f2015-02-03 19:45:46 +0100692 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100693}
694
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100695int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr)
696{
697 struct gprs_gsup_message gsup_msg = {0};
698
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100699 LOGGSUBSCRP(LOGL_INFO, subscr,
700 "subscriber auth info is not available\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100701
702 gsup_msg.message_type = GPRS_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
703 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
704}
705
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100706int gprs_subscr_location_update(struct gsm_subscriber *subscr)
707{
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100708 struct gprs_gsup_message gsup_msg = {0};
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100709
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100710 LOGGSUBSCRP(LOGL_INFO, subscr,
711 "subscriber data is not available\n");
Jacob Erlbecka6ddc2d2014-12-12 15:01:37 +0100712
713 gsup_msg.message_type = GPRS_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
714 return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100715}
716
717void gprs_subscr_update(struct gsm_subscriber *subscr)
718{
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100719 LOGGSUBSCRP(LOGL_DEBUG, subscr, "Updating subscriber data\n");
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100720
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100721 subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100722 subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT;
723
Jacob Erlbeck555b2e52015-01-26 13:52:42 +0100724 if (subscr->sgsn_data->mm)
725 sgsn_update_subscriber_data(subscr->sgsn_data->mm);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100726}
727
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100728void gprs_subscr_update_auth_info(struct gsm_subscriber *subscr)
729{
Jacob Erlbeckbf34c672014-12-23 14:24:16 +0100730 LOGGSUBSCRP(LOGL_DEBUG, subscr,
731 "Updating subscriber authentication info\n");
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100732
733 subscr->flags &= ~GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING;
734 subscr->flags &= ~GSM_SUBSCRIBER_FIRST_CONTACT;
735
Jacob Erlbeck555b2e52015-01-26 13:52:42 +0100736 if (subscr->sgsn_data->mm)
737 sgsn_update_subscriber_data(subscr->sgsn_data->mm);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100738}
739
740struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100741{
742 struct gsm_subscriber *subscr = NULL;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100743
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100744 if (mmctx->subscr)
745 return subscr_get(mmctx->subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100746
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100747 if (mmctx->imsi[0])
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100748 subscr = gprs_subscr_get_by_imsi(mmctx->imsi);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100749
750 if (!subscr) {
751 subscr = gprs_subscr_get_or_create(mmctx->imsi);
752 subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT;
Jacob Erlbeck65fa3f72015-01-06 16:32:41 +0100753 subscr->flags &= ~GPRS_SUBSCRIBER_ENABLE_PURGE;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100754 }
755
756 if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) {
757 strncpy(subscr->equipment.imei, mmctx->imei, GSM_IMEI_LENGTH-1);
758 subscr->equipment.imei[GSM_IMEI_LENGTH-1] = 0;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100759 }
760
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100761 if (subscr->lac != mmctx->ra.lac)
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100762 subscr->lac = mmctx->ra.lac;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100763
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100764 subscr->sgsn_data->mm = mmctx;
765 mmctx->subscr = subscr_get(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100766
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100767 return subscr;
768}
769
770int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx)
771{
772 struct gsm_subscriber *subscr = NULL;
773 int rc;
774
775 LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber data update\n");
776
777 subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
778
779 subscr->flags |= GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING;
780
781 rc = gprs_subscr_location_update(subscr);
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100782 subscr_put(subscr);
Jacob Erlbeck98a95ac2014-11-28 14:55:25 +0100783 return rc;
784}
785
786int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx)
787{
788 struct gsm_subscriber *subscr = NULL;
789 int rc;
790
791 LOGMMCTXP(LOGL_DEBUG, mmctx, "Requesting subscriber authentication info\n");
792
793 subscr = gprs_subscr_get_or_create_by_mmctx(mmctx);
794
795 subscr->flags |= GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING;
796
797 rc = gprs_subscr_query_auth_info(subscr);
798 subscr_put(subscr);
799 return rc;
Jacob Erlbeck33b6dad2014-11-12 10:12:11 +0100800}